SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
14 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
1.5 KB · 16 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2set -euo pipefail3cd "$(dirname "$0")/../../../.."4source scripts/lib.sh5MODEL="${MODEL:-claude-haiku-4-5-20251001}"6# Custom client tool, forced with tool_choice {type: tool}, then the tool_result round trip.7# STATUS: LIVE_VERIFIED 2026-09-18 (identical requests a1_forced_tool + a2_tool_result_final, claude-haiku-4-5-20251001, ~$0.002).8TOOLS='[{"name":"get_weather","description":"Get the current weather for a city. Returns a short text description.","input_schema":{"type":"object","properties":{"location":{"type":"string","description":"City name, e.g. Paris"}},"required":["location"]}}]'9R1=$(ant POST /v1/messages -d "$(jq -n --argjson t "$TOOLS" --arg m "$MODEL" '{model:$m,max_tokens:200,tools:$t,tool_choice:{type:"tool",name:"get_weather"},messages:[{role:"user",content:"Weather in Paris?"}]}')")10log_request anthropic POST /v1/messages "$ANT_STATUS" 0.001 "custom-tools/basic.sh step1 forced tool_choice"11echo "$R1" | jq -c '.stop_reason, (.content[]|select(.type=="tool_use"))'12TU_ID=$(echo "$R1" | jq -r '.content[]|select(.type=="tool_use")|.id')13R2=$(ant POST /v1/messages -d "$(jq -n --argjson t "$TOOLS" --arg m "$MODEL" --argjson a "$(echo "$R1"|jq '.content')" --arg id "$TU_ID" '{model:$m,max_tokens:60,tools:$t,messages:[{role:"user",content:"Weather in Paris?"},{role:"assistant",content:$a},{role:"user",content:[{type:"tool_result",tool_use_id:$id,content:"18 C, light rain"}]}]}')")14log_request anthropic POST /v1/messages "$ANT_STATUS" 0.001 "custom-tools/basic.sh step2 tool_result"15echo "$R2" | jq -c '.stop_reason, .content'16