From 1aab8629ddd8ba617cf59d2e3072b8929c3cf97a Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 4 Sep 2025 13:52:23 -0300 Subject: [PATCH] test: add tests for stream with and without tool calls --- providertests/provider_test.go | 138 ++++++++++++++++++ .../TestStream/anthropic-claude-sonnet.yaml | 32 ++++ .../testdata/TestStream/openai-gpt-4o.yaml | 32 ++++ .../anthropic-claude-sonnet.yaml | 61 ++++++++ .../TestStreamWithTools/openai-gpt-4o.yaml | 61 ++++++++ 5 files changed, 324 insertions(+) create mode 100644 providertests/testdata/TestStream/anthropic-claude-sonnet.yaml create mode 100644 providertests/testdata/TestStream/openai-gpt-4o.yaml create mode 100644 providertests/testdata/TestStreamWithTools/anthropic-claude-sonnet.yaml create mode 100644 providertests/testdata/TestStreamWithTools/openai-gpt-4o.yaml diff --git a/providertests/provider_test.go b/providertests/provider_test.go index 81cb0cb521388fa0d5d594b7145a9973424bd85e..fa30a55e78a6b5895de7fe86bf556717fd82031c 100644 --- a/providertests/provider_test.go +++ b/providertests/provider_test.go @@ -2,6 +2,7 @@ package providertests import ( "context" + "strconv" "strings" "testing" @@ -82,3 +83,140 @@ func TestTool(t *testing.T) { }) } } + +func TestStream(t *testing.T) { + for _, pair := range languageModelBuilders { + t.Run(pair.name, func(t *testing.T) { + r := newRecorder(t) + + languageModel, err := pair.builder(r) + if err != nil { + t.Fatalf("failed to build language model: %v", err) + } + + agent := ai.NewAgent( + languageModel, + ai.WithSystemPrompt("You are a helpful assistant"), + ) + + var collectedText strings.Builder + textDeltaCount := 0 + stepCount := 0 + + streamCall := ai.AgentStreamCall{ + Prompt: "Count from 1 to 3 in Spanish", + OnTextDelta: func(id, text string) error { + textDeltaCount++ + collectedText.WriteString(text) + return nil + }, + OnStepFinish: func(step ai.StepResult) error { + stepCount++ + return nil + }, + } + + result, err := agent.Stream(t.Context(), streamCall) + if err != nil { + t.Fatalf("failed to stream: %v", err) + } + + finalText := result.Response.Content.Text() + if finalText == "" { + t.Fatal("expected non-empty response") + } + + if !strings.Contains(strings.ToLower(finalText), "uno") || + !strings.Contains(strings.ToLower(finalText), "dos") || + !strings.Contains(strings.ToLower(finalText), "tres") { + t.Fatalf("unexpected response: %q", finalText) + } + + if textDeltaCount == 0 { + t.Fatal("expected at least one text delta callback") + } + + if stepCount == 0 { + t.Fatal("expected at least one step finish callback") + } + + if collectedText.String() == "" { + t.Fatal("expected collected text from deltas to be non-empty") + } + }) + } +} + +func TestStreamWithTools(t *testing.T) { + for _, pair := range languageModelBuilders { + t.Run(pair.name, func(t *testing.T) { + r := newRecorder(t) + + languageModel, err := pair.builder(r) + if err != nil { + t.Fatalf("failed to build language model: %v", err) + } + + type CalculatorInput struct { + A int `json:"a" description:"first number"` + B int `json:"b" description:"second number"` + } + + calculatorTool := ai.NewAgentTool( + "add", + "Add two numbers", + func(ctx context.Context, input CalculatorInput, _ ai.ToolCall) (ai.ToolResponse, error) { + result := input.A + input.B + return ai.NewTextResponse(strings.TrimSpace(strconv.Itoa(result))), nil + }, + ) + + agent := ai.NewAgent( + languageModel, + ai.WithSystemPrompt("You are a helpful assistant. Use the add tool to perform calculations."), + ai.WithTools(calculatorTool), + ) + + toolCallCount := 0 + toolResultCount := 0 + var collectedText strings.Builder + + streamCall := ai.AgentStreamCall{ + Prompt: "What is 15 + 27?", + OnTextDelta: func(id, text string) error { + collectedText.WriteString(text) + return nil + }, + OnToolCall: func(toolCall ai.ToolCallContent) error { + toolCallCount++ + if toolCall.ToolName != "add" { + t.Errorf("unexpected tool name: %s", toolCall.ToolName) + } + return nil + }, + OnToolResult: func(result ai.ToolResultContent) error { + toolResultCount++ + return nil + }, + } + + result, err := agent.Stream(t.Context(), streamCall) + if err != nil { + t.Fatalf("failed to stream: %v", err) + } + + finalText := result.Response.Content.Text() + if !strings.Contains(finalText, "42") { + t.Fatalf("expected response to contain '42', got: %q", finalText) + } + + if toolCallCount == 0 { + t.Fatal("expected at least one tool call") + } + + if toolResultCount == 0 { + t.Fatal("expected at least one tool result") + } + }) + } +} diff --git a/providertests/testdata/TestStream/anthropic-claude-sonnet.yaml b/providertests/testdata/TestStream/anthropic-claude-sonnet.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5ece02f5e096e81ccff49add8bd61a1e2b32e1e --- /dev/null +++ b/providertests/testdata/TestStream/anthropic-claude-sonnet.yaml @@ -0,0 +1,32 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 227 + host: "" + body: "{\"max_tokens\":4096,\"messages\":[{\"content\":[{\"text\":\"Count from 1 to 3 in Spanish\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-sonnet-4-20250514\",\"system\":[{\"text\":\"You are a helpful assistant\",\"type\":\"text\"}],\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Anthropic/Go 1.10.0 + url: https://api.anthropic.com/v1/messages + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_01LC9keN4A55kbF4ZSERTbqh\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-sonnet-4-20250514\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":23,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":1,\"service_tier\":\"standard\"}} }\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"1 - uno\"} }\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"\\n2 - dos \\n3\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" - tres\"} }\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0 }\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":23,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":19} }\n\nevent: message_stop\ndata: {\"type\":\"message_stop\" }\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 924.937333ms diff --git a/providertests/testdata/TestStream/openai-gpt-4o.yaml b/providertests/testdata/TestStream/openai-gpt-4o.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac47d448270599f6b3e55bb8729eb2460df89433 --- /dev/null +++ b/providertests/testdata/TestStream/openai-gpt-4o.yaml @@ -0,0 +1,32 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 200 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant\",\"role\":\"system\"},{\"content\":\"Count from 1 to 3 in Spanish\",\"role\":\"user\"}],\"model\":\"gpt-4o\",\"stream_options\":{\"include_usage\":true},\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - OpenAI/Go 2.3.0 + url: https://api.openai.com/v1/chat/completions + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "data: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"iussH0LBg1XxJN\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Sure\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Ut9uBKsz3oTx\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"7GBuOOfjVIPLjDY\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" In\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"d9GWSSttWv8lN\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Spanish\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"ptr1Mq2J\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\",\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"KrKRxanTn8EuWAe\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" counting\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"KzaUquV\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" from\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"FkX07hTx3TF\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"2ZMZIj2oiXvLcxn\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"1\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"UX1rge5Ob1J0kOI\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"BAGM5tj5WkNjW\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"qQ0ETIlKihAOAE7\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"3\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Gl1TPKRizlWwiwI\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" is\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"SF4BgD7Pw39gI\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\":\\n\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"B40X3SCV1tv\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"1\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"ZUpUw67SCpRAtht\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"3bNT0rvK44BGeqi\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Uno\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"L6bruBJ5A7fA\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"tPHymjAuf4HtlD\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"2\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"C4lbztDMhus6xvv\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"JBrRK1Ly6feOSPa\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Dos\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"zMXBzcxHyuX6\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"6YPK2aWh7M9ACK\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"3\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"V8BqeMEkcu7GvU5\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"nfRygsLG3J6zfnG\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Tres\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"23HCbgMjAso\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"q71xDuvFhX\"}\n\ndata: {\"id\":\"chatcmpl-CC7KTblMWEfVKNHjLNnFwvi0m8DFE\",\"object\":\"chat.completion.chunk\",\"created\":1757004145,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[],\"usage\":{\"prompt_tokens\":25,\"completion_tokens\":25,\"total_tokens\":50,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"EBBsHlGQYAdi5Z6\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.619950917s diff --git a/providertests/testdata/TestStreamWithTools/anthropic-claude-sonnet.yaml b/providertests/testdata/TestStreamWithTools/anthropic-claude-sonnet.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d67c96cb5596b896e764598cf07354fc2cf84a39 --- /dev/null +++ b/providertests/testdata/TestStreamWithTools/anthropic-claude-sonnet.yaml @@ -0,0 +1,61 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 553 + host: "" + body: "{\"max_tokens\":4096,\"messages\":[{\"content\":[{\"text\":\"What is 15 + 27?\",\"type\":\"text\"}],\"role\":\"user\"}],\"model\":\"claude-sonnet-4-20250514\",\"system\":[{\"text\":\"You are a helpful assistant. Use the add tool to perform calculations.\",\"type\":\"text\"}],\"tool_choice\":{\"disable_parallel_tool_use\":false,\"type\":\"auto\"},\"tools\":[{\"input_schema\":{\"properties\":{\"a\":{\"description\":\"first number\",\"type\":\"integer\"},\"b\":{\"description\":\"second number\",\"type\":\"integer\"}},\"required\":[\"a\",\"b\"],\"type\":\"object\"},\"name\":\"add\",\"description\":\"Add two numbers\"}],\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Anthropic/Go 1.10.0 + url: https://api.anthropic.com/v1/messages + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_01KtoJaXMqmtVtLnjtX5cPUT\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-sonnet-4-20250514\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":420,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":8,\"service_tier\":\"standard\"}} }\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"I'll help you calculate 15 \"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"+ 27 using the add function.\"}}\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"toolu_015ewucD8KduCw15A5kPth7R\",\"name\":\"add\",\"input\":{}} }\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"a\\\":\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\" 15\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\", \\\"b\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"\\\": \"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"27}\"} }\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1 }\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":420,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":86}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\" }\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.174656584s +- id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 900 + host: "" + body: "{\"max_tokens\":4096,\"messages\":[{\"content\":[{\"text\":\"What is 15 + 27?\",\"type\":\"text\"}],\"role\":\"user\"},{\"content\":[{\"text\":\"I'll help you calculate 15 + 27 using the add function.\",\"type\":\"text\"},{\"id\":\"toolu_015ewucD8KduCw15A5kPth7R\",\"input\":{\"a\":15,\"b\":27},\"name\":\"add\",\"type\":\"tool_use\"}],\"role\":\"assistant\"},{\"content\":[{\"tool_use_id\":\"toolu_015ewucD8KduCw15A5kPth7R\",\"content\":[{\"text\":\"42\",\"type\":\"text\"}],\"type\":\"tool_result\"}],\"role\":\"user\"}],\"model\":\"claude-sonnet-4-20250514\",\"system\":[{\"text\":\"You are a helpful assistant. Use the add tool to perform calculations.\",\"type\":\"text\"}],\"tool_choice\":{\"disable_parallel_tool_use\":false,\"type\":\"auto\"},\"tools\":[{\"input_schema\":{\"properties\":{\"a\":{\"description\":\"first number\",\"type\":\"integer\"},\"b\":{\"description\":\"second number\",\"type\":\"integer\"}},\"required\":[\"a\",\"b\"],\"type\":\"object\"},\"name\":\"add\",\"description\":\"Add two numbers\"}],\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Anthropic/Go 1.10.0 + url: https://api.anthropic.com/v1/messages + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_01DNqLDbjh3SijUzzFvKZJYX\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"claude-sonnet-4-20250514\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":519,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":1,\"service_tier\":\"standard\"}} }\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"15\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" + 27 = 42\"} }\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0 }\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":519,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":12} }\n\nevent: message_stop\ndata: {\"type\":\"message_stop\" }\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.181155542s diff --git a/providertests/testdata/TestStreamWithTools/openai-gpt-4o.yaml b/providertests/testdata/TestStreamWithTools/openai-gpt-4o.yaml new file mode 100644 index 0000000000000000000000000000000000000000..045f3e59936f1705c272935684c336c92eedbe50 --- /dev/null +++ b/providertests/testdata/TestStreamWithTools/openai-gpt-4o.yaml @@ -0,0 +1,61 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 527 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant. Use the add tool to perform calculations.\",\"role\":\"system\"},{\"content\":\"What is 15 + 27?\",\"role\":\"user\"}],\"model\":\"gpt-4o\",\"stream_options\":{\"include_usage\":true},\"tool_choice\":\"auto\",\"tools\":[{\"function\":{\"name\":\"add\",\"strict\":false,\"description\":\"Add two numbers\",\"parameters\":{\"properties\":{\"a\":{\"description\":\"first number\",\"type\":\"integer\"},\"b\":{\"description\":\"second number\",\"type\":\"integer\"}},\"required\":[\"a\",\"b\"],\"type\":\"object\"}},\"type\":\"function\"}],\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - OpenAI/Go 2.3.0 + url: https://api.openai.com/v1/chat/completions + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "data: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":null,\"tool_calls\":[{\"index\":0,\"id\":\"call_32EKgZToXJGCcoOsKGeKDBMG\",\"type\":\"function\",\"function\":{\"name\":\"add\",\"arguments\":\"\"}}],\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"G\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"{\\\"\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"o83\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"a\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Sqazb\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"\\\":\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"ytC\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"15\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Jt63\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\",\\\"\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"UEV\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"b\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"lGxRz\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"\\\":\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"72d\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"27\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"D0VY\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"}\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"VyN2Q\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"tool_calls\"}],\"usage\":null,\"obfuscation\":\"lUEs\"}\n\ndata: {\"id\":\"chatcmpl-CC7KWfg68JP1ntmxrXmMcjeGwt2yf\",\"object\":\"chat.completion.chunk\",\"created\":1757004148,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[],\"usage\":{\"prompt_tokens\":73,\"completion_tokens\":17,\"total_tokens\":90,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"u6D1A99gV8BIvOR\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.275977s +- id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 758 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant. Use the add tool to perform calculations.\",\"role\":\"system\"},{\"content\":\"What is 15 + 27?\",\"role\":\"user\"},{\"tool_calls\":[{\"id\":\"call_32EKgZToXJGCcoOsKGeKDBMG\",\"function\":{\"arguments\":\"{\\\"a\\\":15,\\\"b\\\":27}\",\"name\":\"add\"},\"type\":\"function\"}],\"role\":\"assistant\"},{\"content\":\"42\",\"tool_call_id\":\"call_32EKgZToXJGCcoOsKGeKDBMG\",\"role\":\"tool\"}],\"model\":\"gpt-4o\",\"stream_options\":{\"include_usage\":true},\"tool_choice\":\"auto\",\"tools\":[{\"function\":{\"name\":\"add\",\"strict\":false,\"description\":\"Add two numbers\",\"parameters\":{\"properties\":{\"a\":{\"description\":\"first number\",\"type\":\"integer\"},\"b\":{\"description\":\"second number\",\"type\":\"integer\"}},\"required\":[\"a\",\"b\"],\"type\":\"object\"}},\"type\":\"function\"}],\"stream\":true}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - OpenAI/Go 2.3.0 + url: https://api.openai.com/v1/chat/completions + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + content_length: -1 + body: "data: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"lHQy6EEWHTpR9e\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"15\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"4l3v3yNWlz6ezS\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" +\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"jBTpHdjr9xDqYh\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"10oJvn7BeIA3iry\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"27\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"NFNSh8QNVa9Fl5\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" is\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"ayv5ohnA1tCWD\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"B81ro7bFywRKLgj\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"42\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"lDVhH4mGOWHn0L\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"CUsaGMVGQyyqVbK\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"1lVNWlWnms\"}\n\ndata: {\"id\":\"chatcmpl-CC7KYLaQy1yokH0JcpuncBILcIrSc\",\"object\":\"chat.completion.chunk\",\"created\":1757004150,\"model\":\"gpt-4o-2024-08-06\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_f33640a400\",\"choices\":[],\"usage\":{\"prompt_tokens\":98,\"completion_tokens\":9,\"total_tokens\":107,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"xStpLtBU1J2gDbA\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.835219083s