@@ -12,27 +12,27 @@ import (
1212func TestDecodeFinishReason (t * testing.T ) {
1313 tests := []struct {
1414 name string
15- finishReason anthropic.BetaMessageStopReason
15+ finishReason anthropic.BetaStopReason
1616 want api.FinishReason
1717 }{
1818 {
1919 name : "end_turn maps to stop" ,
20- finishReason : anthropic .BetaMessageStopReasonEndTurn ,
20+ finishReason : anthropic .BetaStopReasonEndTurn ,
2121 want : api .FinishReasonStop ,
2222 },
2323 {
2424 name : "stop_sequence maps to stop" ,
25- finishReason : anthropic .BetaMessageStopReasonStopSequence ,
25+ finishReason : anthropic .BetaStopReasonStopSequence ,
2626 want : api .FinishReasonStop ,
2727 },
2828 {
2929 name : "tool_use maps to tool-calls" ,
30- finishReason : anthropic .BetaMessageStopReasonToolUse ,
30+ finishReason : anthropic .BetaStopReasonToolUse ,
3131 want : api .FinishReasonToolCalls ,
3232 },
3333 {
3434 name : "max_tokens maps to length" ,
35- finishReason : anthropic .BetaMessageStopReasonMaxTokens ,
35+ finishReason : anthropic .BetaStopReasonMaxTokens ,
3636 want : api .FinishReasonLength ,
3737 },
3838 {
@@ -171,13 +171,13 @@ func TestDecodeProviderMetadata(t *testing.T) {
171171func TestDecodeReasoning (t * testing.T ) {
172172 tests := []struct {
173173 name string
174- block anthropic.BetaContentBlock
174+ block anthropic.BetaContentBlockUnion
175175 want api.Reasoning
176176 }{
177177 {
178178 name : "thinking block" ,
179- block : anthropic.BetaContentBlock {
180- Type : anthropic . BetaContentBlockTypeThinking ,
179+ block : anthropic.BetaContentBlockUnion {
180+ Type : "thinking" ,
181181 Thinking : "This is my reasoning" ,
182182 Signature : "sig123" ,
183183 },
@@ -188,8 +188,8 @@ func TestDecodeReasoning(t *testing.T) {
188188 },
189189 {
190190 name : "redacted thinking block" ,
191- block : anthropic.BetaContentBlock {
192- Type : anthropic . BetaContentBlockTypeRedactedThinking ,
191+ block : anthropic.BetaContentBlockUnion {
192+ Type : "redacted_thinking" ,
193193 Data : "redacted-data" ,
194194 },
195195 want : & api.RedactedReasoningBlock {
@@ -198,22 +198,22 @@ func TestDecodeReasoning(t *testing.T) {
198198 },
199199 {
200200 name : "empty thinking block" ,
201- block : anthropic.BetaContentBlock {
202- Type : anthropic . BetaContentBlockTypeThinking ,
201+ block : anthropic.BetaContentBlockUnion {
202+ Type : "thinking" ,
203203 },
204204 want : nil ,
205205 },
206206 {
207207 name : "empty redacted thinking block" ,
208- block : anthropic.BetaContentBlock {
209- Type : anthropic . BetaContentBlockTypeRedactedThinking ,
208+ block : anthropic.BetaContentBlockUnion {
209+ Type : "redacted_thinking" ,
210210 },
211211 want : nil ,
212212 },
213213 {
214214 name : "non-reasoning block" ,
215- block : anthropic.BetaContentBlock {
216- Type : anthropic . BetaContentBlockTypeText ,
215+ block : anthropic.BetaContentBlockUnion {
216+ Type : "text" ,
217217 },
218218 want : nil ,
219219 },
@@ -230,15 +230,15 @@ func TestDecodeReasoning(t *testing.T) {
230230func TestDecodeToolUse (t * testing.T ) {
231231 tests := []struct {
232232 name string
233- block anthropic.BetaContentBlock
233+ block anthropic.BetaContentBlockUnion
234234 want * api.ToolCallBlock
235235 }{
236236 {
237237 name : "block with input" ,
238- block : anthropic.BetaContentBlock {
238+ block : anthropic.BetaContentBlockUnion {
239239 ID : "call_123" ,
240240 Name : "search" ,
241- Type : anthropic . BetaContentBlockTypeToolUse ,
241+ Type : "tool_use" ,
242242 Input : json .RawMessage (`{"query":"test"}` ),
243243 },
244244 want : & api.ToolCallBlock {
@@ -249,10 +249,10 @@ func TestDecodeToolUse(t *testing.T) {
249249 },
250250 {
251251 name : "block without input" ,
252- block : anthropic.BetaContentBlock {
252+ block : anthropic.BetaContentBlockUnion {
253253 ID : "call_456" ,
254254 Name : "get_time" ,
255- Type : anthropic . BetaContentBlockTypeToolUse ,
255+ Type : "tool_use" ,
256256 },
257257 want : & api.ToolCallBlock {
258258 ToolCallID : "call_456" ,
@@ -275,10 +275,10 @@ func TestDecodeToolUse(t *testing.T) {
275275// TestDecodeToolUseWithMarshalError tests the decodeToolUse function when JSON marshaling fails
276276func TestDecodeToolUseWithMarshalError (t * testing.T ) {
277277 // Test with malformed JSON to trigger the marshal error path
278- block := anthropic.BetaContentBlock {
278+ block := anthropic.BetaContentBlockUnion {
279279 ID : "call_789" ,
280280 Name : "error_call" ,
281- Type : anthropic . BetaContentBlockTypeToolUse ,
281+ Type : "tool_use" ,
282282 Input : json .RawMessage (`{malformed json` ), // Invalid JSON
283283 }
284284
@@ -297,22 +297,22 @@ func TestDecodeToolUseWithMarshalError(t *testing.T) {
297297func TestDecodeContent (t * testing.T ) {
298298 tests := []struct {
299299 name string
300- blocks []anthropic.BetaContentBlock
300+ blocks []anthropic.BetaContentBlockUnion
301301 want []api.ContentBlock
302302 }{
303303 {
304304 name : "multiple block types" ,
305- blocks : []anthropic.BetaContentBlock {
305+ blocks : []anthropic.BetaContentBlockUnion {
306306 {
307- Type : anthropic . BetaContentBlockTypeText ,
307+ Type : "text" ,
308308 Text : "Hello world" ,
309309 },
310310 {
311- Type : anthropic . BetaContentBlockTypeThinking ,
311+ Type : "thinking" ,
312312 Thinking : "Thinking process" ,
313313 },
314314 {
315- Type : anthropic . BetaContentBlockTypeToolUse ,
315+ Type : "tool_use" ,
316316 ID : "call_789" ,
317317 Name : "get_weather" ,
318318 Input : json .RawMessage (`{"location":"New York"}` ),
@@ -339,22 +339,22 @@ func TestDecodeContent(t *testing.T) {
339339 },
340340 {
341341 name : "empty blocks" ,
342- blocks : []anthropic.BetaContentBlock {},
342+ blocks : []anthropic.BetaContentBlockUnion {},
343343 want : []api.ContentBlock {},
344344 },
345345 {
346346 name : "empty text block should be skipped" ,
347- blocks : []anthropic.BetaContentBlock {
347+ blocks : []anthropic.BetaContentBlockUnion {
348348 {
349- Type : anthropic . BetaContentBlockTypeText ,
349+ Type : "text" ,
350350 Text : "" , // Empty text should be skipped
351351 },
352352 },
353353 want : []api.ContentBlock {},
354354 },
355355 {
356356 name : "unknown block type should be skipped" ,
357- blocks : []anthropic.BetaContentBlock {
357+ blocks : []anthropic.BetaContentBlockUnion {
358358 {
359359 Type : "" , // Unknown type
360360 Text : "Should be skipped" ,
@@ -384,14 +384,14 @@ func TestDecodeResponse(t *testing.T) {
384384 msg : & anthropic.BetaMessage {
385385 ID : "msg_123" ,
386386 Model : "claude-3" ,
387- StopReason : anthropic .BetaMessageStopReasonEndTurn ,
387+ StopReason : anthropic .BetaStopReasonEndTurn ,
388388 Usage : anthropic.BetaUsage {
389389 InputTokens : 150 ,
390390 OutputTokens : 250 ,
391391 },
392- Content : []anthropic.BetaContentBlock {
392+ Content : []anthropic.BetaContentBlockUnion {
393393 {
394- Type : anthropic . BetaContentBlockTypeText ,
394+ Type : "text" ,
395395 Text : "Hello, I am Claude" ,
396396 },
397397 },
0 commit comments