| 9 | ) |
| 10 | |
| 11 | func TestParserBasicSingleCall(t *testing.T) { |
| 12 | p := NewParser() |
| 13 | text, calls := p.Feed("I will read the file. <tool_call>{\"name\":\"read\",\"arguments\":{\"filePath\":\"/tmp/x\"}}</tool_call>") |
| 14 | if text != "I will read the file. " { |
| 15 | t.Fatalf("text = %q", text) |
| 16 | } |
| 17 | if len(calls) != 1 { |
| 18 | t.Fatalf("calls = %d, want 1", len(calls)) |
| 19 | } |
| 20 | if calls[0].Function.Name != "read" || calls[0].Function.Arguments != `{"filePath":"/tmp/x"}` { |
| 21 | t.Fatalf("call = %#v", calls[0]) |
| 22 | } |
| 23 | if !strings.HasPrefix(calls[0].ID, "call_") { |
| 24 | t.Fatalf("id = %q, want call_ prefix", calls[0].ID) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | func TestParserStreamingChunked(t *testing.T) { |
| 29 | p := NewParser() |