@@ -69,6 +69,7 @@ runner_args() {
6969 local runner=" $1 " model=" $2 " prompt=" $3 " steps=" $4 " temp=" $5 " doc=" ${6:- } " output=" ${7:- } "
7070
7171 case " $runner " in
72+ skainet) echo " -m ${model} -s ${steps} -k ${temp} \" ${prompt} \" " ;;
7273 kllama) echo " -m ${model} -s ${steps} -k ${temp} \" ${prompt} \" " ;;
7374 kgemma) echo " ${model} \" ${prompt} \" ${steps} ${temp} " ;;
7475 kqwen) echo " ${model} \" ${prompt} \" ${steps} ${temp} " ;;
@@ -254,9 +255,93 @@ print(f'M_OUTPUT={repr(m.get(\"output\", \"\"))}')
254255 separator
255256 done
256257
258+ # ── Tool Calling Tests ───────────────────────────────────────────
259+ TC_COUNT=$( python3 -c "
260+ import json
261+ cfg = json.load(open('${CONFIG_FILE} '))
262+ print(sum(1 for m in cfg['models'] if m.get('toolCalling')))
263+ " )
264+
265+ declare -a tc_results=()
266+ tc_pass=0
267+ tc_fail=0
268+
269+ if [[ " $TC_COUNT " -gt 0 ]]; then
270+ echo " "
271+ echo -e " ${BOLD} Tool Calling Tests${RESET} ($TC_COUNT models)"
272+ separator
273+
274+ kllama_task=$( runner_task " kllama" )
275+
276+ for i in $( seq 0 $(( MODEL_COUNT - 1 )) ) ; do
277+ eval " $( python3 -c "
278+ import json
279+ cfg = json.load(open('${CONFIG_FILE} '))
280+ m = cfg['models'][$i ]
281+ tc = m.get('toolCalling')
282+ if tc is None:
283+ print('TC_ENABLED=false')
284+ else:
285+ print('TC_ENABLED=true')
286+ print(f'TC_PROMPT={repr(tc.get(\" prompt\" , \" What is 2 + 2?\" ))}')
287+ print(f'TC_STEPS={tc.get(\" steps\" , 256)}')
288+ print(f'M_NAME={repr(m[\" name\" ])}')
289+ print(f'M_MODEL={repr(m[\" model\" ])}')
290+ " ) "
291+
292+ [[ " $TC_ENABLED " != " true" ]] && continue
293+
294+ M_MODEL=$( expand_path " $M_MODEL " )
295+
296+ echo -e " \n${BOLD} Model:${RESET} $M_NAME (tool calling)"
297+ echo -e " ${BOLD} Prompt:${RESET} \" $TC_PROMPT \" "
298+
299+ if [[ ! -e " $M_MODEL " ]]; then
300+ echo -e " ${RED} FAIL${RESET} (model path not found)"
301+ tc_fail=$(( tc_fail + 1 ))
302+ tc_results+=(" FAIL|$M_NAME |not found|-" )
303+ separator
304+ continue
305+ fi
306+
307+ start_ts=$( python3 -c ' import time; print(time.time())' )
308+ output_file=$( mktemp)
309+ exit_code=0
310+
311+ $GRADLE " $kllama_task " --quiet \
312+ --args=" -m ${M_MODEL} --demo -s ${TC_STEPS} -k 0.7 \" ${TC_PROMPT} \" " \
313+ > " $output_file " 2>&1 || exit_code=$?
314+
315+ end_ts=$( python3 -c ' import time; print(time.time())' )
316+ wall_sec=$( python3 -c " print(f'{$end_ts - $start_ts :.1f}')" )
317+
318+ if [[ $exit_code -ne 0 ]]; then
319+ echo -e " ${RED} FAIL${RESET} (exit $exit_code , wall ${wall_sec} s)"
320+ tail -5 " $output_file " | sed ' s/^/ │ /'
321+ tc_fail=$(( tc_fail + 1 ))
322+ tc_results+=(" FAIL|$M_NAME |exit $exit_code |${wall_sec} s" )
323+ elif grep -q ' \[Tool Call\]' " $output_file " ; then
324+ tool_name=$( grep -oE ' \[Tool Call\] [a-z_]+' " $output_file " | head -1 | sed ' s/\[Tool Call\] //' )
325+ echo -e " ${GREEN} OK${RESET} tool called: ${CYAN}${tool_name}${RESET} wall: ${wall_sec} s"
326+ grep ' \[Tool Call\]' " $output_file " | head -2 | sed ' s/^/ │ /'
327+ grep ' \[Tool Result\]' " $output_file " | head -2 | sed ' s/^/ │ /'
328+ tc_pass=$(( tc_pass + 1 ))
329+ tc_results+=(" OK|$M_NAME |$tool_name |${wall_sec} s" )
330+ else
331+ echo -e " ${YELLOW} WARN${RESET} (no tool call detected, wall ${wall_sec} s)"
332+ tail -5 " $output_file " | sed ' s/^/ │ /'
333+ tc_fail=$(( tc_fail + 1 ))
334+ tc_results+=(" WARN|$M_NAME |no tool call|${wall_sec} s" )
335+ fi
336+
337+ rm -f " $output_file "
338+ separator
339+ done
340+ fi
341+
257342 # ── Summary ──────────────────────────────────────────────────────
258343 echo " "
259- echo -e " ${BOLD} Summary${RESET} "
344+ echo -e " ${BOLD} Summary — Generation ${RESET} "
260345 separator
261346 printf " %-6s %-30s %-8s %8s %10s %8s\n" " Status" " Model" " Runner" " Size" " tok/s" " Wall"
262347 separator
@@ -272,6 +357,29 @@ print(f'M_OUTPUT={repr(m.get(\"output\", \"\"))}')
272357 done
273358 separator
274359 echo -e " ${GREEN} Pass: $pass ${RESET} ${RED} Fail: $fail ${RESET} Total: ${MODEL_COUNT} "
360+
361+ if [[ " $TC_COUNT " -gt 0 ]]; then
362+ echo " "
363+ echo -e " ${BOLD} Summary — Tool Calling${RESET} "
364+ separator
365+ printf " %-6s %-30s %-15s %8s\n" " Status" " Model" " Tool" " Wall"
366+ separator
367+ for r in " ${tc_results[@]} " ; do
368+ IFS=' |' read -r status name tool wall <<< " $r"
369+ if [[ " $status " == " OK" ]]; then
370+ color=" $GREEN "
371+ elif [[ " $status " == " WARN" ]]; then
372+ color=" $YELLOW "
373+ else
374+ color=" $RED "
375+ fi
376+ printf " ${color} %-6s${RESET} %-30s %-15s %8s\n" \
377+ " $status " " ${name: 0: 30} " " $tool " " $wall "
378+ done
379+ separator
380+ echo -e " ${GREEN} Pass: $tc_pass ${RESET} ${RED} Fail: $tc_fail ${RESET} Total: ${TC_COUNT} "
381+ fi
382+
275383 echo " "
276384 exit 0
277385fi
0 commit comments