diff --git a/providertests/builders_test.go b/providertests/builders_test.go index 3d5e080ce4b8f1d09a1c32c6ff055dff0c599ab4..72d122de3b1cb832e681af574dccb0072f2e10e5 100644 --- a/providertests/builders_test.go +++ b/providertests/builders_test.go @@ -19,6 +19,7 @@ type builderPair struct { var languageModelBuilders = []builderPair{ {"openai-gpt-4o", builderOpenaiGpt4o}, + {"openai-gpt-4o-mini", builderOpenaiGpt4oMini}, {"anthropic-claude-sonnet", builderAnthropicClaudeSonnet4}, } @@ -34,6 +35,18 @@ func builderOpenaiGpt4o(r *recorder.Recorder) (ai.LanguageModel, error) { return model, nil } +func builderOpenaiGpt4oMini(r *recorder.Recorder) (ai.LanguageModel, error) { + provider := openai.New( + openai.WithAPIKey(os.Getenv("OPENAI_API_KEY")), + openai.WithHTTPClient(&http.Client{Transport: r}), + ) + model, err := provider.LanguageModel("gpt-4o-mini") + if err != nil { + return nil, err + } + return model, nil +} + func builderAnthropicClaudeSonnet4(r *recorder.Recorder) (ai.LanguageModel, error) { provider := anthropic.New( anthropic.WithAPIKey(os.Getenv("ANTHROPIC_API_KEY")), diff --git a/providertests/testdata/TestSimple/openai-gpt-4o-mini.yaml b/providertests/testdata/TestSimple/openai-gpt-4o-mini.yaml new file mode 100644 index 0000000000000000000000000000000000000000..662adf566db7182adec747e3b5ac6f1de2ef58a2 --- /dev/null +++ b/providertests/testdata/TestSimple/openai-gpt-4o-mini.yaml @@ -0,0 +1,33 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 143 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant\",\"role\":\"system\"},{\"content\":\"Say hi in Portuguese\",\"role\":\"user\"}],\"model\":\"gpt-4o-mini\"}" + 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 + uncompressed: true + body: "{\n \"id\": \"chatcmpl-CC86Cz7oEjbaC9INACjv4rZgUqkui\",\n \"object\": \"chat.completion\",\n \"created\": 1757007104,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"Olá!\",\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 20,\n \"completion_tokens\": 2,\n \"total_tokens\": 22,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n \"system_fingerprint\": \"fp_e665f7564b\"\n}\n" + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 1.377235042s diff --git a/providertests/testdata/TestStream/openai-gpt-4o-mini.yaml b/providertests/testdata/TestStream/openai-gpt-4o-mini.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f033bf5dd1900b4e7cf3ce0223f563d7ef18cfce --- /dev/null +++ b/providertests/testdata/TestStream/openai-gpt-4o-mini.yaml @@ -0,0 +1,32 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 205 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant\",\"role\":\"system\"},{\"content\":\"Count from 1 to 3 in Spanish\",\"role\":\"user\"}],\"model\":\"gpt-4o-mini\",\"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-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"MdM0iUdCi\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Sure\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"0WYvyGg\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"O4x0jEzy77\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Here\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"hFhgoZ\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" is\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"21niu3eg\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" the\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Q1U79RV\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" counting\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"n3\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" from\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"m8aW0r\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"SoH0gBsrYI\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"1\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"RDpov9RJ21\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Pd02xohG\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"YEupeYkvgT\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"3\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"xPQZkPJmmD\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" in\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"x8LjLQvm\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Spanish\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"HXj\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\":\\n\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"6GrBPJ\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"1\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"dmyuaXYXjr\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"XXstNKfoS7\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Uno\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Z38XQzw\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"L5vhFF9y7\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"2\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Q2P9ThvZgh\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"WIIywHPwle\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Dos\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"c3CsgGA\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"\\n\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"CNPc8eacZ\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"3\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"eFqdAD3vb8\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"pc8kDYYOmv\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Tres\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"NjLFvL\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"BMBVR\"}\n\ndata: {\"id\":\"chatcmpl-CC86GJzAnNH4KeIucQvSjcw9ApvP1\",\"object\":\"chat.completion.chunk\",\"created\":1757007108,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_e665f7564b\",\"choices\":[],\"usage\":{\"prompt_tokens\":25,\"completion_tokens\":26,\"total_tokens\":51,\"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\":\"WnRGyJ1PLM\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 1.171848125s diff --git a/providertests/testdata/TestStreamWithTools/openai-gpt-4o-mini.yaml b/providertests/testdata/TestStreamWithTools/openai-gpt-4o-mini.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3699cbc24355fb1a2bb06f7da7348906091038f0 --- /dev/null +++ b/providertests/testdata/TestStreamWithTools/openai-gpt-4o-mini.yaml @@ -0,0 +1,61 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 532 + 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-mini\",\"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-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":null,\"tool_calls\":[{\"index\":0,\"id\":\"call_SexxPUavmIXkdPj9YCY86rAv\",\"type\":\"function\",\"function\":{\"name\":\"add\",\"arguments\":\"\"}}],\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Bi5lh4c7wm9V\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"{\\\"\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"9slbQBld7uDfGx\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"a\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"\\\":\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"In7gVcr4gFp8AQ\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"15\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"E8J66QfDmefl0se\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\",\\\"\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"OQRle4Kd1hRgyU\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"b\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"\\\":\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"8Nz9jINTs9JpkR\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"27\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"1Qv0gJNAeyn9KCl\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"}\"}}]},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"tool_calls\"}],\"usage\":null,\"obfuscation\":\"NViWjR1EBYC8EUs\"}\n\ndata: {\"id\":\"chatcmpl-CC86HU3sn6BghCHd9nGYvSrbG8Nq6\",\"object\":\"chat.completion.chunk\",\"created\":1757007109,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"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\":\"Twq5TqPXwD\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 852.636542ms +- id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 763 + 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_SexxPUavmIXkdPj9YCY86rAv\",\"function\":{\"arguments\":\"{\\\"a\\\":15,\\\"b\\\":27}\",\"name\":\"add\"},\"type\":\"function\"}],\"role\":\"assistant\"},{\"content\":\"42\",\"tool_call_id\":\"call_SexxPUavmIXkdPj9YCY86rAv\",\"role\":\"tool\"}],\"model\":\"gpt-4o-mini\",\"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-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"6dNsxDRYv\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"15\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"eeOggkItX\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" +\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"eTh8CvrQp\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"Y4Xvam5bns\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"27\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"taAs18INA\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" equals\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"QqWb\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" \"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"UKNosA2zT5\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"42\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"2eSH3S32n\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\".\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"qeXjwKLKsA\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"grITR\"}\n\ndata: {\"id\":\"chatcmpl-CC86I0sQZB3BScMjD1Vlq9r4LNG7K\",\"object\":\"chat.completion.chunk\",\"created\":1757007110,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_8bda4d3a2c\",\"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\":\"8R73BwOCQi\"}\n\ndata: [DONE]\n\n" + headers: + Content-Type: + - text/event-stream; charset=utf-8 + status: 200 OK + code: 200 + duration: 709.664625ms diff --git a/providertests/testdata/TestTool/openai-gpt-4o-mini.yaml b/providertests/testdata/TestTool/openai-gpt-4o-mini.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0e0310b933061055088c14d5e6693f108bcaf1d6 --- /dev/null +++ b/providertests/testdata/TestTool/openai-gpt-4o-mini.yaml @@ -0,0 +1,63 @@ +--- +version: 2 +interactions: +- id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 429 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant\",\"role\":\"system\"},{\"content\":\"What's the weather in Florence?\",\"role\":\"user\"}],\"model\":\"gpt-4o-mini\",\"tool_choice\":\"auto\",\"tools\":[{\"function\":{\"name\":\"weather\",\"strict\":false,\"description\":\"Get weather information for a location\",\"parameters\":{\"properties\":{\"location\":{\"description\":\"the city\",\"type\":\"string\"}},\"required\":[\"location\"],\"type\":\"object\"}},\"type\":\"function\"}]}" + 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 + uncompressed: true + body: "{\n \"id\": \"chatcmpl-CC86DuEym05aNFxLlzEELyWrWahas\",\n \"object\": \"chat.completion\",\n \"created\": 1757007105,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n \"id\": \"call_P1Q6WfBaX0ZdGvLJC4TacMGY\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"weather\",\n \"arguments\": \"{\\\"location\\\":\\\"Florence\\\"}\"\n }\n }\n ],\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 59,\n \"completion_tokens\": 14,\n \"total_tokens\": 73,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n \"system_fingerprint\": \"fp_8bda4d3a2c\"\n}\n" + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 1.524888209s +- id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 674 + host: "" + body: "{\"messages\":[{\"content\":\"You are a helpful assistant\",\"role\":\"system\"},{\"content\":\"What's the weather in Florence?\",\"role\":\"user\"},{\"tool_calls\":[{\"id\":\"call_P1Q6WfBaX0ZdGvLJC4TacMGY\",\"function\":{\"arguments\":\"{\\\"location\\\":\\\"Florence\\\"}\",\"name\":\"weather\"},\"type\":\"function\"}],\"role\":\"assistant\"},{\"content\":\"40 C\",\"tool_call_id\":\"call_P1Q6WfBaX0ZdGvLJC4TacMGY\",\"role\":\"tool\"}],\"model\":\"gpt-4o-mini\",\"tool_choice\":\"auto\",\"tools\":[{\"function\":{\"name\":\"weather\",\"strict\":false,\"description\":\"Get weather information for a location\",\"parameters\":{\"properties\":{\"location\":{\"description\":\"the city\",\"type\":\"string\"}},\"required\":[\"location\"],\"type\":\"object\"}},\"type\":\"function\"}]}" + 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 + uncompressed: true + body: "{\n \"id\": \"chatcmpl-CC86FlWw0t13MgwmVeuzu5irpjyS2\",\n \"object\": \"chat.completion\",\n \"created\": 1757007107,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"The weather in Florence is currently 40°C.\",\n \"refusal\": null,\n \"annotations\": []\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 82,\n \"completion_tokens\": 11,\n \"total_tokens\": 93,\n \"prompt_tokens_details\": {\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\": {\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\": 0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\": \"default\",\n \"system_fingerprint\": \"fp_8bda4d3a2c\"\n}\n" + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: 1.421106917s