From 790a2de57bf9c30a8aabe473e5262d2125d7b9b2 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 22 Apr 2024 21:27:53 +0200 Subject: [PATCH] fix(openai): function + tool calling (#223) --- package-lock.json | 9 +- .../src/SemanticAttributes.ts | 2 +- packages/instrumentation-openai/package.json | 2 +- .../recording.har | 40 +-- .../recording.har | 38 +-- .../recording.har | 36 +-- .../recording.har | 48 ++-- .../recording.har | 244 ++++++++++++++++++ .../recording.har | 36 +-- .../recording.har | 36 +-- .../recording.har | 48 ++-- .../recording.har | 244 ++++++++++++++++++ .../src/instrumentation.ts | 57 ++++ .../test/instrumentation.test.ts | 202 ++++++++++++++- 14 files changed, 892 insertions(+), 150 deletions(-) create mode 100644 packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-function-calling_1703714575/recording.har create mode 100644 packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-tool-calling_1747151373/recording.har diff --git a/package-lock.json b/package-lock.json index 8b8e685e..15029486 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17830,15 +17830,14 @@ } }, "node_modules/openai": { - "version": "4.28.4", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.28.4.tgz", - "integrity": "sha512-RNIwx4MT/F0zyizGcwS+bXKLzJ8QE9IOyigDG/ttnwB220d58bYjYFp0qjvGwEFBO6+pvFVIDABZPGDl46RFsg==", + "version": "4.38.3", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.38.3.tgz", + "integrity": "sha512-mIL9WtrFNOanpx98mJ+X/wkoepcxdqqu0noWFoNQHl/yODQ47YM7NEYda7qp8JfjqpLFVxY9mQhshoS/Fqac0A==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", "abort-controller": "^3.0.0", "agentkeepalive": "^4.2.1", - "digest-fetch": "^1.3.0", "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", "node-fetch": "^2.6.7", @@ -23423,7 +23422,7 @@ "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", "mocha": "^10.2.0", - "openai": "^4.12.4", + "openai": "^4.38.3", "ts-mocha": "^10.0.0" }, "engines": { diff --git a/packages/ai-semantic-conventions/src/SemanticAttributes.ts b/packages/ai-semantic-conventions/src/SemanticAttributes.ts index 3208b1da..ef6b0682 100644 --- a/packages/ai-semantic-conventions/src/SemanticAttributes.ts +++ b/packages/ai-semantic-conventions/src/SemanticAttributes.ts @@ -31,7 +31,7 @@ export const SpanAttributes = { LLM_PROMPTS: "llm.prompts", LLM_COMPLETIONS: "llm.completions", LLM_CHAT_STOP_SEQUENCES: "llm.chat.stop_sequences", - + LLM_REQUEST_FUNCTIONS: "llm.request.functions", // Vector DB VECTOR_DB_VENDOR: "db.system", VECTOR_DB_QUERY_TOP_K: "db.vector.query.top_k", diff --git a/packages/instrumentation-openai/package.json b/packages/instrumentation-openai/package.json index a75269ea..5e26143b 100644 --- a/packages/instrumentation-openai/package.json +++ b/packages/instrumentation-openai/package.json @@ -48,7 +48,7 @@ "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", "mocha": "^10.2.0", - "openai": "^4.12.4", + "openai": "^4.38.3", "ts-mocha": "^10.0.0" }, "homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-openai", diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har index 307f4879..1e8f6e80 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.28.4" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.28.4" + "value": "4.38.3" }, { "_fromType": "array", @@ -63,7 +63,7 @@ { "_fromType": "array", "name": "x-stainless-runtime-version", - "value": "v20.9.0" + "value": "v18.17.1" }, { "_fromType": "array", @@ -75,7 +75,7 @@ "value": "api.openai.com" } ], - "headersSize": 469, + "headersSize": 470, "httpVersion": "HTTP/1.1", "method": "POST", "postData": { @@ -87,23 +87,23 @@ "url": "https://api.openai.com/v1/chat/completions" }, "response": { - "bodySize": 1275, + "bodySize": 1147, "content": { "encoding": "base64", "mimeType": "application/json", - "size": 1275, - "text": "[\"H4sIAAAAAAAAA+RZS2/aQBC+8yu2e8kF0L4fXCIlh6a9VKoi9ZBEyJhNcGN7LXvdJo3y3ysbCARbZhNieigHhGZnzHwzO08/DQCA0RxOAAwXgQuTLB5pSfTXOEj5n3OndZmdffl+HtrPUl3cJxdwWEnY2U8TurXUOLRJFhsX2XR5HOYmcKZ6KpYY\",\"M0G54vVBYucmrsTuMjeiYz5yZT6zI4QJX0kubBSaAk7A1QAAAJ7q70rHdG4e4ASg4ZqSmKII7gycvDABAHMbVxQYFEVUuCB1cLg5DG3qTFqr/WPxCObRHLiFAd8yk16a2CTG5Y9gbn6Z2GYmB7PcBPegzMDvyC0qzigHYRCHZRw4m5+C6/Q6PTNhUBYGRA6Etozn6YkDiyCdx2YtUJvmASQmKMrcJCZ1xSe40un5BUxs77LczorXaDYKX70QwRZDzeTsvUlXmLbQbj8WTsAIjRFCSBNNGRI7bLNHt2XzzUfJ4Q4FI9YgEfyKcjPc1S+bbsG7utk6fh564Koc1Q0MS8wpk8wTFiVNWKhJ4i1cPSN1C9OJFFMppKD6/UCx8HEp6tulVcx1I2WUMcXej1TqJvYWv+MmV89OvuxysR4jpSgTzIykb5Ae332rXNmBg4+FFFphaka+yQYj5eMepL2c2Lzm+F9krnUx6b7rAnNOifjY9NViFD8DN7kwfm8ssZ4NXNfoTuMqLsWu/m8wrVY+F6kJXbeUTtmzMcpsb/2XjHHJDqkfsuUq9Iyr6r/2IiMSUyoYPgCa9ukBWgto/21B1J1CkKAECyn7bwy8bNS3QTZteIdVyBhxJPy73Zbg1z5hrfaLtYVNi5z0qmPHT7On3eULI8IR9Y08QXu+HNVc1qEwHiOtED8gVFqKbb+QVlNmdwbgVAvNsS8uIXyqmE8AtJUEfvyRInLd9iFSMr3bAr3J7W3FoO9EVy8VuoExyrnGlH1gmmtNMj4prK0T7Ts6Tty+5oBwxbX0dr0+vp+XO6M9sz9SXNED7i/zCWbkNVyo48f3/iaIUI6xxv9LD7TcLO6ZLJnCmtCeUwPy27V4jZ+k7x3b9ia2u3tERGl0yFSu3zcotlTPthrLPnBdgrw6T96vaz7taXCIZggx7uuQA/rMl983jU39bZRGxWKam6CwtdaFs9lyoV+J1X8Dy1dvJmCW2yRz0xpo9WdrB8PNi5PN4TpaobMuiDd0qgYrPWDxWDiTTG+j9M7kWR4t32ncZlM6C/GMSyZCOHge/AUAAP//AwBzJcGg3RkAAA==\"]" + "size": 1147, + "text": "[\"H4sIAAAAAAAAA8RYS2/aQBC+8ys2e8kF0D7sfXCJmkrNpU0vaakURcjYi3Fjey17aUqj/PfKhgDBlllBTDhYaHbWnm9mZ+bbee4BAKMAjgD0557xkyweyBtzG8Zm/O82+/lLjcfujy/fPt3MRHz99fMj7Jc79PS38s3rrqGvkyxWJtLpatnPlWdU+Q==\",\"VswxFZhihqqFRAcqLreFmRnQoTswi3yqBwgTd71zriNfFXAE7nsAAPBcPUsb00D9hSNQvaeSJKoovFDB0UYJAJjruJRAryiiwnipgf3toq9To9LK7PF8CYIoAGauwPdMpXcqVoky+RIE6o+KdaZyEGpgdKmRe9nyClwr31sUqhQsga8XcZBeGmByz69kUQ70UwpmSsVRGhYXcP3dl43BsQ6zXE+LtxZvjbrfCMGOQqVk9KNK13bvINp9LRyBARoihDARjiMdsqc2XZodv25/gvf3JBg5NRHBbyQP/X37sskOvPuHneWXvgWuMhjtwLAQzEEYW8KipA4L1UVug1bHSM1ctSIlyHUIleJ4oJjZhBR1HdIyr1qRYkQQIowdjZTLOvaGuOO6VsdBvmsLMR8KyShWA26boucP3roatqAgQ4EZkpSogW0AMRI2wUHSKoT1Q44/om69tov2k86RK513rl0NPrHzb10L42MTyenYv6FudSxzJEeUneBY2uCMrjtAGyY6RJxgzOm71v/uMa1o0gFyIgVnDLPuW5tFbZDc5sx3XUCuDnEBIhCxPQuMdhzlNQdur3UCc4Lw8fyFMYuASmkTzwaRe34iVN4Y2hODOlwg5rofkBidd8jVVakVv8OxYOx49FJadTRu0wobOm3XbPHSHLzTIcqFfd1scAfr+oyX9+BWGC6ilCPyvm3NoqpL+SEZH7UzQuQ4hCC6T+3PkvINt97OeZx+ai8BHGNM5AkMuSnh5dlTeTP/OXBzcgU+odgjK25uR/2bDgOyoslut668ODAPolJwbD8mOYEabf4/1GZ6syiNivkkV16hK6sLo7PV6K/cVn0GLt7MKWGW6yQzkwpo+bHXkwC3Y9TtIlnHAhptvHgrp6X3KztgsSyMSiazKA1VnuXRasI5yyY+IdJVnHoB7L30/gMAAP//AwDW79xN6xUAAA==\"]" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-03-26T15:03:06.000Z", + "expires": "2024-04-22T19:42:40.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "NSvtgcpHDAZH8AoO_Q3Fs891okiS7Q6hLT3SnrcOBwU-1711463586-1.0.1.1-V0N7G8e04Q6qGUM2kttPlubgExssnQCvgCLWNiMhYluTe977KL43Vod7W8BP6i1eHJfuqvmhP7rQvYHKbtd3oQ" + "value": "3S7nFjQIeVqiriw6xIQiXnrh5rNZGFk24qbLEosQImk-1713813160-1.0.1.1-A6uQAPUGKB0lMQ6lF.vwP3Dpgaa83WwhlZ0voEImwl3uAQmmYxkOou_a0wtblhj_6bd_CgTNgyYrVfhnSCOfCA" }, { "domain": ".api.openai.com", @@ -112,13 +112,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "Z6InQeWS_HG8r5P1wLAtd437vS85HwnVd_Ne.wam2No-1711463586368-0.0.1.1-604800000" + "value": "kbUq6yDBUrJ.tFnbx3NklUCqY.1oT7.eEDORno5hrYA-1713813160752-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 26 Mar 2024 14:33:06 GMT" + "value": "Mon, 22 Apr 2024 19:12:40 GMT" }, { "name": "content-type", @@ -150,7 +150,7 @@ }, { "name": "openai-processing-ms", - "value": "1000" + "value": "657" }, { "name": "openai-version", @@ -186,7 +186,7 @@ }, { "name": "x-request-id", - "value": "req_422be004a8b88e2f5c7f0969d7d0edb6" + "value": "req_829d9c57bfc8c994a6d6f2b07b1a31c5" }, { "name": "cf-cache-status", @@ -195,12 +195,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=NSvtgcpHDAZH8AoO_Q3Fs891okiS7Q6hLT3SnrcOBwU-1711463586-1.0.1.1-V0N7G8e04Q6qGUM2kttPlubgExssnQCvgCLWNiMhYluTe977KL43Vod7W8BP6i1eHJfuqvmhP7rQvYHKbtd3oQ; path=/; expires=Tue, 26-Mar-24 15:03:06 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=3S7nFjQIeVqiriw6xIQiXnrh5rNZGFk24qbLEosQImk-1713813160-1.0.1.1-A6uQAPUGKB0lMQ6lF.vwP3Dpgaa83WwhlZ0voEImwl3uAQmmYxkOou_a0wtblhj_6bd_CgTNgyYrVfhnSCOfCA; path=/; expires=Mon, 22-Apr-24 19:42:40 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=Z6InQeWS_HG8r5P1wLAtd437vS85HwnVd_Ne.wam2No-1711463586368-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=kbUq6yDBUrJ.tFnbx3NklUCqY.1oT7.eEDORno5hrYA-1713813160752-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -208,7 +208,7 @@ }, { "name": "cf-ray", - "value": "86a7da8f1c1109c7-HFA" + "value": "8787ed3969e26d85-MUC" }, { "name": "content-encoding", @@ -219,14 +219,14 @@ "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1209, + "headersSize": 1208, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-26T14:33:04.955Z", - "time": 1405, + "startedDateTime": "2024-04-22T19:12:39.832Z", + "time": 901, "timings": { "blocked": -1, "connect": -1, @@ -234,7 +234,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 1405 + "wait": 901 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har index a0ee4f82..aa7034d8 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.28.4" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.28.4" + "value": "4.38.3" }, { "_fromType": "array", @@ -63,7 +63,7 @@ { "_fromType": "array", "name": "x-stainless-runtime-version", - "value": "v20.9.0" + "value": "v18.17.1" }, { "_fromType": "array", @@ -75,7 +75,7 @@ "value": "api.openai.com" } ], - "headersSize": 469, + "headersSize": 470, "httpVersion": "HTTP/1.1", "method": "POST", "postData": { @@ -87,22 +87,22 @@ "url": "https://api.openai.com/v1/chat/completions" }, "response": { - "bodySize": 8436, + "bodySize": 8439, "content": { "mimeType": "text/event-stream", - "size": 8436, - "text": "data: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":{\"content\":[]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":{\"content\":[{\"token\":\"Why\",\"logprob\":-0.00009293406,\"bytes\":[87,104,121],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" was\"},\"logprobs\":{\"content\":[{\"token\":\" was\",\"logprob\":-4.6151624,\"bytes\":[32,119,97,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":{\"content\":[{\"token\":\" Open\",\"logprob\":-1.1642329,\"bytes\":[32,79,112,101,110],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":{\"content\":[{\"token\":\"Te\",\"logprob\":-1.504853e-6,\"bytes\":[84,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":{\"content\":[{\"token\":\"lemetry\",\"logprob\":-8.418666e-6,\"bytes\":[108,101,109,101,116,114,121],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" always\"},\"logprobs\":{\"content\":[{\"token\":\" always\",\"logprob\":-0.4410347,\"bytes\":[32,97,108,119,97,121,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" invited\"},\"logprobs\":{\"content\":[{\"token\":\" invited\",\"logprob\":-0.72817403,\"bytes\":[32,105,110,118,105,116,101,100],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":{\"content\":[{\"token\":\" to\",\"logprob\":-4.1273333e-6,\"bytes\":[32,116,111],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" parties\"},\"logprobs\":{\"content\":[{\"token\":\" parties\",\"logprob\":-0.42963633,\"bytes\":[32,112,97,114,116,105,101,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":{\"content\":[{\"token\":\"?\",\"logprob\":-0.058331113,\"bytes\":[63],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Because\"},\"logprobs\":{\"content\":[{\"token\":\" Because\",\"logprob\":-0.4165701,\"bytes\":[32,66,101,99,97,117,115,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" it\"},\"logprobs\":{\"content\":[{\"token\":\" it\",\"logprob\":-0.0036803598,\"bytes\":[32,105,116],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" always\"},\"logprobs\":{\"content\":[{\"token\":\" always\",\"logprob\":-0.8409865,\"bytes\":[32,97,108,119,97,121,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" knew\"},\"logprobs\":{\"content\":[{\"token\":\" knew\",\"logprob\":-0.39374557,\"bytes\":[32,107,110,101,119],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" how\"},\"logprobs\":{\"content\":[{\"token\":\" how\",\"logprob\":-0.0024843349,\"bytes\":[32,104,111,119],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":{\"content\":[{\"token\":\" to\",\"logprob\":-2.8160932e-6,\"bytes\":[32,116,111],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" trace\"},\"logprobs\":{\"content\":[{\"token\":\" trace\",\"logprob\":-0.034341197,\"bytes\":[32,116,114,97,99,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":{\"content\":[{\"token\":\" its\",\"logprob\":-1.0400136,\"bytes\":[32,105,116,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" steps\"},\"logprobs\":{\"content\":[{\"token\":\" steps\",\"logprob\":-0.9814062,\"bytes\":[32,115,116,101,112,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" back\"},\"logprobs\":{\"content\":[{\"token\":\" back\",\"logprob\":-0.121362045,\"bytes\":[32,98,97,99,107],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" home\"},\"logprobs\":{\"content\":[{\"token\":\" home\",\"logprob\":-0.59598184,\"bytes\":[32,104,111,109,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":{\"content\":[{\"token\":\"!\",\"logprob\":-0.08101034,\"bytes\":[33],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9729KUZ5ugWRZXplEfCQ3yfDJUsDS\",\"object\":\"chat.completion.chunk\",\"created\":1711463586,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_3bc1b5746c\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" + "size": 8439, + "text": "data: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":{\"content\":[]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":{\"content\":[{\"token\":\"Why\",\"logprob\":-0.00011284107,\"bytes\":[87,104,121],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" did\"},\"logprobs\":{\"content\":[{\"token\":\" did\",\"logprob\":-0.017106479,\"bytes\":[32,100,105,100],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":{\"content\":[{\"token\":\" Open\",\"logprob\":-2.1018867,\"bytes\":[32,79,112,101,110],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":{\"content\":[{\"token\":\"Te\",\"logprob\":-1.147242e-6,\"bytes\":[84,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":{\"content\":[{\"token\":\"lemetry\",\"logprob\":-8.061054e-6,\"bytes\":[108,101,109,101,116,114,121],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" go\"},\"logprobs\":{\"content\":[{\"token\":\" go\",\"logprob\":-1.2131933,\"bytes\":[32,103,111],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":{\"content\":[{\"token\":\" to\",\"logprob\":-0.0024028856,\"bytes\":[32,116,111],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" therapy\"},\"logprobs\":{\"content\":[{\"token\":\" therapy\",\"logprob\":-0.08782522,\"bytes\":[32,116,104,101,114,97,112,121],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":{\"content\":[{\"token\":\"?\",\"logprob\":-0.09496602,\"bytes\":[63],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Because\"},\"logprobs\":{\"content\":[{\"token\":\" Because\",\"logprob\":-0.33834884,\"bytes\":[32,66,101,99,97,117,115,101],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" it\"},\"logprobs\":{\"content\":[{\"token\":\" it\",\"logprob\":-0.00081784645,\"bytes\":[32,105,116],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" couldn\"},\"logprobs\":{\"content\":[{\"token\":\" couldn\",\"logprob\":-1.6877398,\"bytes\":[32,99,111,117,108,100,110],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"'t\"},\"logprobs\":{\"content\":[{\"token\":\"'t\",\"logprob\":-0.00007862962,\"bytes\":[39,116],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" stop\"},\"logprobs\":{\"content\":[{\"token\":\" stop\",\"logprob\":-1.0809197,\"bytes\":[32,115,116,111,112],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" tracing\"},\"logprobs\":{\"content\":[{\"token\":\" tracing\",\"logprob\":-0.3275078,\"bytes\":[32,116,114,97,99,105,110,103],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":{\"content\":[{\"token\":\" its\",\"logprob\":-0.00765395,\"bytes\":[32,105,116,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" problems\"},\"logprobs\":{\"content\":[{\"token\":\" problems\",\"logprob\":-1.0159718,\"bytes\":[32,112,114,111,98,108,101,109,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" back\"},\"logprobs\":{\"content\":[{\"token\":\" back\",\"logprob\":-0.023997031,\"bytes\":[32,98,97,99,107],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":{\"content\":[{\"token\":\" to\",\"logprob\":-0.00008304016,\"bytes\":[32,116,111],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":{\"content\":[{\"token\":\" its\",\"logprob\":-0.08851753,\"bytes\":[32,105,116,115],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" childhood\"},\"logprobs\":{\"content\":[{\"token\":\" childhood\",\"logprob\":-0.402673,\"bytes\":[32,99,104,105,108,100,104,111,111,100],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":{\"content\":[{\"token\":\"!\",\"logprob\":-0.31191415,\"bytes\":[33],\"top_logprobs\":[]}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNhtS4d0wTjADwNjesFWVuom2YG\",\"object\":\"chat.completion.chunk\",\"created\":1713813161,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-03-26T15:03:07.000Z", + "expires": "2024-04-22T19:42:41.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "cOFGzW4OT9AbCSn.GIXvBC6nKWVicG4Bu02QxhVpRos-1711463587-1.0.1.1-oFygEOBt.qFQwCt.7OVnFEayutoMnCZSfzfH.irYA2SKSWqUNR6gNHwQ5uI9SSPTM70aFngybT_GFKZ4oxCbHQ" + "value": "IvxGWemz.5Jwf1cgeGFExmv4X71ZJgqBTZo6Ws5Rdds-1713813161-1.0.1.1-H.NKYWAKbPRQQD5z8kx6kRLTujnbmh0tgo0414TIQTeesswMV3XFIXzO_A6QHZ69qcYciPeVvveDqKhzP7aWSA" }, { "domain": ".api.openai.com", @@ -111,13 +111,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "qM4T0xFclhxL5faD7uiJZtFFnBcCGppOfGFm86bJ80o-1711463587032-0.0.1.1-604800000" + "value": "0fF0ycXWpvqZTZNZqzOtzIEKs1c5LVBwtBGsgzQLSQg-1713813161316-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 26 Mar 2024 14:33:07 GMT" + "value": "Mon, 22 Apr 2024 19:12:41 GMT" }, { "name": "content-type", @@ -149,7 +149,7 @@ }, { "name": "openai-processing-ms", - "value": "284" + "value": "289" }, { "name": "openai-version", @@ -185,7 +185,7 @@ }, { "name": "x-request-id", - "value": "req_fa5cb63147235b6c5edb1c016f7e3cda" + "value": "req_0e578659002bdfe62b6ad1fb8898cece" }, { "name": "cf-cache-status", @@ -194,12 +194,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=cOFGzW4OT9AbCSn.GIXvBC6nKWVicG4Bu02QxhVpRos-1711463587-1.0.1.1-oFygEOBt.qFQwCt.7OVnFEayutoMnCZSfzfH.irYA2SKSWqUNR6gNHwQ5uI9SSPTM70aFngybT_GFKZ4oxCbHQ; path=/; expires=Tue, 26-Mar-24 15:03:07 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=IvxGWemz.5Jwf1cgeGFExmv4X71ZJgqBTZo6Ws5Rdds-1713813161-1.0.1.1-H.NKYWAKbPRQQD5z8kx6kRLTujnbmh0tgo0414TIQTeesswMV3XFIXzO_A6QHZ69qcYciPeVvveDqKhzP7aWSA; path=/; expires=Mon, 22-Apr-24 19:42:41 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=qM4T0xFclhxL5faD7uiJZtFFnBcCGppOfGFm86bJ80o-1711463587032-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=0fF0ycXWpvqZTZNZqzOtzIEKs1c5LVBwtBGsgzQLSQg-1713813161316-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -207,7 +207,7 @@ }, { "name": "cf-ray", - "value": "86a7da979b8c09c7-HFA" + "value": "8787ed3f1cb96d85-MUC" }, { "name": "alt-svc", @@ -220,8 +220,8 @@ "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-03-26T14:33:06.376Z", - "time": 1054, + "startedDateTime": "2024-04-22T19:12:40.742Z", + "time": 953, "timings": { "blocked": -1, "connect": -1, @@ -229,7 +229,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 1054 + "wait": 953 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har index 63812148..e02a62de 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.26.0" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.26.0" + "value": "4.38.3" }, { "_fromType": "array", @@ -87,23 +87,23 @@ "url": "https://api.openai.com/v1/chat/completions" }, "response": { - "bodySize": 499, + "bodySize": 531, "content": { "encoding": "base64", "mimeType": "application/json", - "size": 499, - "text": "[\"H4sIAAAAAAAAA1RRsU7DMBDd8xWHF5YWNQ2haRckGCpggAGJAaHKca6JW8dn2Rdoi/rvyGlpYbnhvXvv3t19JwBCV2IGQjWSVevMsOievnb38zu1TtPx9GFVPhYmnc+Ll+fdyolBVFC5QsW/qitFrTPImuyBVh4lY3RNJ6PiOpvk06wnWqrQRFnteJhd5UPufA==\",\"ScNROs6Pyoa0wiBm8J4AAHz3NWa0FW7EDEaDX6TFEGSNYnZqAhCeTESEDEEHlpbF4Ewqsoy2j/3WbKHSFXCD8OzQvqLBFtlvocJPNOTQQ01QelrjLdyhkl3A2L0FRZ2p7CUDe6nWEdMecOPQBgwX4jhuf8ppqHaeyriT7Yw54UttdWgWHmUgGzMFJneQ7xOAj/4e3b8VhfPUOl4wrdFGwzQ/2InzB/6QxZFkYmnOeJYlx3wibANju1hqW6N3Xh+Os3SLm2kxnmbjvBqJZJ/8AAAA//8DAJipMFgmAgAA\"]" + "size": 531, + "text": "[\"H4sIAAAAAAAAA1RRwU4bMRC971dMfeklQWyWLU0ulaIWEEJwIBISqIq89qzt4vUYexaIUP4d7SYk6mUO7817evPmowAQTosFCGUlqy766fySb5vV2cWDXt00V9fL9tHc69/qx/LP0ryIyaCg5h8q/lKdKOqiR3YUdrRKKBkH1/K8rH6WVVnXI9GR\",\"Rj/ITORpdVJPuU8NTU/LWb1XWnIKs1jAUwEA8DHOIWPQ+C4WcDr5QjrMWRoUi8MSgEjkB0TInF1mGVhMjqSiwBjG2A92A9ppYItwFzGs0GOHnDag8RU9RUzQJJTP0Ed4c2zBugzGJd8mh0H/giUq2WeEbBEU9V6H7wxWBu0RpPfjPiepXDAggwZPxrhgvol9nu3hEE8mJmqGo0Pv/QFvXXDZrhPKTGEInZniTr4tAP6OhfX/dSBioi7ymukZw2BY1js7cXzRkZyd7Ukmlv6IV/Nin0/kTWbs1q0LBlNMbtdeG9dqNpvXeF5JLYpt8QkAAP//AwBdFbbTRwIAAA==\"]" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-02-20T14:29:54.000Z", + "expires": "2024-04-22T19:42:36.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "qnFwbDd8pwRrbVlCWvIQfM6g0Ztv.zQbMSH3UD8TJMM-1708437594-1.0-AZrEHjnwVg9yt9zb4WCr8QBhucenCKkWuCH9RnlH8Sa1s0zzNtz/cvmLNxOH0thJWyvIomF3JdvcsCkqNIo0vKU=" + "value": "q5OuIvnhFhBGbpH55TzvYmYDVL3Ag4OF31.WArF_pkQ-1713813156-1.0.1.1-OLd7nKQHw8M9GgsXj0VJxUGOGnhR5VxxBpPo6zyJGPmoYGSZ1F4Sf0SkLe_z2kLUo9IiHU.N3o27X9ONfHhnkA" }, { "domain": ".api.openai.com", @@ -112,13 +112,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "ge1.FwDqR7kM31X_sA3VQ9l44kH.YsxMc9TPGcEX46w-1708437594765-0.0-604800000" + "value": "1MX6eJy_DiemEOP67xXiY1f3nOw7C0e1VMP.eDQoHk4-1713813156569-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 20 Feb 2024 13:59:54 GMT" + "value": "Mon, 22 Apr 2024 19:12:36 GMT" }, { "name": "content-type", @@ -150,7 +150,7 @@ }, { "name": "openai-processing-ms", - "value": "901" + "value": "1012" }, { "name": "openai-version", @@ -186,7 +186,7 @@ }, { "name": "x-request-id", - "value": "req_34d5c6fef4661c7fa5b839c2e0be0c0b" + "value": "req_9365d7f94c8394b14f1d0ef06044af37" }, { "name": "cf-cache-status", @@ -195,12 +195,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=qnFwbDd8pwRrbVlCWvIQfM6g0Ztv.zQbMSH3UD8TJMM-1708437594-1.0-AZrEHjnwVg9yt9zb4WCr8QBhucenCKkWuCH9RnlH8Sa1s0zzNtz/cvmLNxOH0thJWyvIomF3JdvcsCkqNIo0vKU=; path=/; expires=Tue, 20-Feb-24 14:29:54 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=q5OuIvnhFhBGbpH55TzvYmYDVL3Ag4OF31.WArF_pkQ-1713813156-1.0.1.1-OLd7nKQHw8M9GgsXj0VJxUGOGnhR5VxxBpPo6zyJGPmoYGSZ1F4Sf0SkLe_z2kLUo9IiHU.N3o27X9ONfHhnkA; path=/; expires=Mon, 22-Apr-24 19:42:36 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=ge1.FwDqR7kM31X_sA3VQ9l44kH.YsxMc9TPGcEX46w-1708437594765-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=1MX6eJy_DiemEOP67xXiY1f3nOw7C0e1VMP.eDQoHk4-1713813156569-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -208,7 +208,7 @@ }, { "name": "cf-ray", - "value": "858745d06b4bba91-MXP" + "value": "8787ed1c9e796d85-MUC" }, { "name": "content-encoding", @@ -219,14 +219,14 @@ "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1202, + "headersSize": 1209, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-02-20T13:59:53.502Z", - "time": 1256, + "startedDateTime": "2024-04-22T19:12:35.100Z", + "time": 1455, "timings": { "blocked": -1, "connect": -1, @@ -234,7 +234,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 1256 + "wait": 1455 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har index 2fd1a0e9..3323391b 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.26.0" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.26.0" + "value": "4.38.3" }, { "_fromType": "array", @@ -87,23 +87,23 @@ "url": "https://api.openai.com/v1/completions" }, "response": { - "bodySize": 419, + "bodySize": 415, "content": { "encoding": "base64", "mimeType": "application/json", - "size": 419, - "text": "[\"H4sIAAAAAAAAA0SQMW/CMBCF9/yKk+emgkIKzVKJoVXFgCohdWgrZJwjcXF8rn0piRD/vbJBsNzwnr/37nzMAISuRAlCtc7k827Zj3eLP1O84Dv11ZpmK/zd89K+jV7FXXxN2x9UHAnGnjeKWmeQNdmzrTxKxpg4no3m08mseCqS0VKFJmK143xyX+Tc\",\"+S3l2gb2neIL3ZBWGEQJnxkAwDFNOHdF+Mt+2Y9mgIMMwA3CyqFdo8EW2Q8Qp1YgzUEOAYJBdMNzRBaoZBcQNCdSkQ0sLZsh1aYGbSvsRQmjq2Kodp62cRvbGXPVd9rq0Gw8ykA2LmXQ1tyI5J8ygO90SxdkjaK83CCcp9bxhmmPNkbOz3ni9oE3b/x4MZlYmpv+MM1iwyn7BwAA//8DAFplnhi4AQAA\"]" + "size": 415, + "text": "[\"H4sIAAAAAAAAA0SQy07DMBBF9/mKkdcUEdrSNhvEQ0JiASwqQFBUOc4QG5wZy5lIKVX/HTmt2o0X9/g+NNsMQLlKFaBME/xo8SBPOLl7f6TX+6b8s7Mbe9v15uVjoXurztJvLn/QSHII9rI23ASP4pj22ETUgikxn+XjeT7Op/MBNFyhT7Y6yA==\",\"aHw+HUkXSx45aiV2Rg5uy85gqwr4zAAAtsML+65kXtGK3uwGKleBWITngLREjw1K3ICukQRqBibQEFlXINGF6+RaMkjUBoeiIdNRhb0q4OKoeK5D5DL1U+f9Uf925Fq7jqhbpjTDI9Vi1cB3GcDXsL5rdY2qOKxWIXITZC38i5Qi5/s8dTrZieVXBygs2p/0y0mWGnbZPwAAAP//AwCbMrwFqgEAAA==\"]" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-02-20T14:29:55.000Z", + "expires": "2024-04-22T19:42:39.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "n_Wb089cQHNUUtwppScwl5aZCQgE.cNGxFWfP5uv0vI-1708437595-1.0-Acd9Sld/6BrgfYHHwGonQ6hcdQNErLFZFLdp7Tp+JX6HDfJu5IRKMegZnMfhdqk4pBhCFm/km6LsBykq0FM5F9s=" + "value": "oSwViHMWIbzf2TOfTqGF.fxTV.HcQjZcARokCHHBSgs-1713813159-1.0.1.1-v2mBZqcpP2HBsJAVlPZMIs7fPl0aa6R5b8bDIaqsRUCnAdrzryjr.uPqEOLzuVkKWx8FhiX7uVXF7BWjmTo9vQ" }, { "domain": ".api.openai.com", @@ -112,13 +112,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "5NtI_SwVe5kB6poYm60TzeF4W_zDiHoArDL10iPni7g-1708437595570-0.0-604800000" + "value": "sJm0sCm3f8I6d4lccwweXIJHTYJq8bEqK3Zpwls8eig-1713813159214-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 20 Feb 2024 13:59:55 GMT" + "value": "Mon, 22 Apr 2024 19:12:39 GMT" }, { "name": "content-type", @@ -150,7 +150,7 @@ }, { "name": "openai-processing-ms", - "value": "507" + "value": "472" }, { "name": "openai-version", @@ -162,31 +162,31 @@ }, { "name": "x-ratelimit-limit-requests", - "value": "3000" + "value": "3500" }, { "name": "x-ratelimit-limit-tokens", - "value": "250000" + "value": "90000" }, { "name": "x-ratelimit-remaining-requests", - "value": "2999" + "value": "3499" }, { "name": "x-ratelimit-remaining-tokens", - "value": "249975" + "value": "89976" }, { "name": "x-ratelimit-reset-requests", - "value": "20ms" + "value": "17ms" }, { "name": "x-ratelimit-reset-tokens", - "value": "5ms" + "value": "16ms" }, { "name": "x-request-id", - "value": "req_82a0636cfbe9b845c70f4d61589b918f" + "value": "req_901b97e572d5abbc6ec84fca87839e11" }, { "name": "cf-cache-status", @@ -195,12 +195,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=n_Wb089cQHNUUtwppScwl5aZCQgE.cNGxFWfP5uv0vI-1708437595-1.0-Acd9Sld/6BrgfYHHwGonQ6hcdQNErLFZFLdp7Tp+JX6HDfJu5IRKMegZnMfhdqk4pBhCFm/km6LsBykq0FM5F9s=; path=/; expires=Tue, 20-Feb-24 14:29:55 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=oSwViHMWIbzf2TOfTqGF.fxTV.HcQjZcARokCHHBSgs-1713813159-1.0.1.1-v2mBZqcpP2HBsJAVlPZMIs7fPl0aa6R5b8bDIaqsRUCnAdrzryjr.uPqEOLzuVkKWx8FhiX7uVXF7BWjmTo9vQ; path=/; expires=Mon, 22-Apr-24 19:42:39 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=5NtI_SwVe5kB6poYm60TzeF4W_zDiHoArDL10iPni7g-1708437595570-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=sJm0sCm3f8I6d4lccwweXIJHTYJq8bEqK3Zpwls8eig-1713813159214-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -208,7 +208,7 @@ }, { "name": "cf-ray", - "value": "858745d7e8ceba91-MXP" + "value": "8787ed3068ad6d85-MUC" }, { "name": "content-encoding", @@ -219,14 +219,14 @@ "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1206, + "headersSize": 1211, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-02-20T13:59:54.776Z", - "time": 725, + "startedDateTime": "2024-04-22T19:12:38.391Z", + "time": 801, "timings": { "blocked": -1, "connect": -1, @@ -234,7 +234,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 725 + "wait": 801 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-function-calling_1703714575/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-function-calling_1703714575/recording.har new file mode 100644 index 00000000..732b5f88 --- /dev/null +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-function-calling_1703714575/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for function calling", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "1315cc1cec39b40b43bce33ca46abc4e", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 730, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "730" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "OpenAI/JS 4.38.3" + }, + { + "_fromType": "array", + "name": "x-stainless-lang", + "value": "js" + }, + { + "_fromType": "array", + "name": "x-stainless-package-version", + "value": "4.38.3" + }, + { + "_fromType": "array", + "name": "x-stainless-os", + "value": "MacOS" + }, + { + "_fromType": "array", + "name": "x-stainless-arch", + "value": "arm64" + }, + { + "_fromType": "array", + "name": "x-stainless-runtime", + "value": "node" + }, + { + "_fromType": "array", + "name": "x-stainless-runtime-version", + "value": "v18.17.1" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "api.openai.com" + } + ], + "headersSize": 470, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What's the weather like in Boston?\"\n }\n ],\n \"functions\": [\n {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n }\n ],\n \"function_call\": \"auto\"\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 476, + "content": { + "encoding": "base64", + "mimeType": "application/json", + "size": 476, + "text": "[\"H4sIAAAAAAAAA1yRT08CMRDF7/spJnMGwwoi7E2j4aQxMTEa12xKmf0D3c6mnY0Ywnc3RdgFL81kXt9vXqe7CACrFSaAulSi68YM5wt5Lu8e9cPkJed8u+G3kXtqlu+v68XHDQ6Cg5dr0nJyXWmuG0NSsf2TtSMlFKjxbTyexeN4Gh+Emldkgq1oZDgZjqbx+OgoudLkMYHPCABgdzhDNruiLSYwGpw6NXmvCsKkuwSAjk3ooPK+8qKs4KAXNVshG+La1pgzIW+tDqkzrYy5AAKgVfUBWZBkunWOrGTfpKQkdwYHQOWKtiYrIT3uUguQomGtAjnFBFK8Zy+hTu0eO+f+WO27lxkuGsdL/y8o5pWtfJk5Up5tGHKZOzrRvg6rbC+2g43jupFMeEM2kGfXf1zsP60X4+lRFBZl+v58Fh2Dov/xQnWWV7Yg17iq22u0j34BAAD//wMAACpE404CAAA=\"]" + }, + "cookies": [ + { + "domain": ".api.openai.com", + "expires": "2024-04-22T19:42:43.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "6MjCXPFYs4R3UevV7rJuXbpwFrJ9ThHcPVTdmllkj3M-1713813163-1.0.1.1-mahKM1eLAbazHKmAaLIRhOVW3nR0pO6KwnPt4dfB.yU86lP8PXsN4d16Yf2a.BBh.is6hJAcWieZj7EHIbt2zA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "tDryygg3V68a_.UXfCq5ziocYVEzg_84QZ0MWn8oFZU-1713813163429-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:43 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "keep-alive" + }, + { + "name": "access-control-allow-origin", + "value": "*" + }, + { + "name": "cache-control", + "value": "no-cache, must-revalidate" + }, + { + "name": "openai-model", + "value": "gpt-4-0613" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "1358" + }, + { + "name": "openai-version", + "value": "2020-10-01" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800; includeSubDomains" + }, + { + "name": "x-ratelimit-limit-requests", + "value": "5000" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "80000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "79974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "19ms" + }, + { + "name": "x-request-id", + "value": "req_30d4df2acf0052d74d7c5ff9c0676a04" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "__cf_bm=6MjCXPFYs4R3UevV7rJuXbpwFrJ9ThHcPVTdmllkj3M-1713813163-1.0.1.1-mahKM1eLAbazHKmAaLIRhOVW3nR0pO6KwnPt4dfB.yU86lP8PXsN4d16Yf2a.BBh.is6hJAcWieZj7EHIbt2zA; path=/; expires=Mon, 22-Apr-24 19:42:43 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "_cfuvid=tDryygg3V68a_.UXfCq5ziocYVEzg_84QZ0MWn8oFZU-1713813163429-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed452fcc6d85-MUC" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1200, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:41.708Z", + "time": 1697, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 1697 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har index 25db8930..1c995235 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.26.0" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.26.0" + "value": "4.38.3" }, { "_fromType": "array", @@ -92,22 +92,22 @@ "url": "https://api.openai.com/v1/chat/completions" }, "response": { - "bodySize": 5554, + "bodySize": 5300, "content": { "mimeType": "text/event-stream", - "size": 5554, - "text": "data: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" did\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" the\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" developer\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" break\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" up\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" with\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Because\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" it\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" couldn\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"'t\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" handle\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" their\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" baggage\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8v0b4xNr7BR77msAgj3x5GcG9xqVU\",\"object\":\"chat.completion.chunk\",\"created\":1708597682,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_cbdb91ce3f\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" + "size": 5300, + "text": "data: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" did\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" the\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" developer\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" go\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" broke\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\\n\\n\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Because\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" they\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" were\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" always\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" tracing\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" their\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" expenses\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNdQf5cDtn29KJgYccVX9rD47KR\",\"object\":\"chat.completion.chunk\",\"created\":1713813157,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-02-22T10:58:02.000Z", + "expires": "2024-04-22T19:42:37.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "WbDF2EtunDK9RwRxX89DLO_atDDNL9uWiI6Q9igUlbI-1708597682-1.0-AathLYxhkJeQwWYT2s4L3LdY++n9kbv8RoVR3ZaUfkwqtgqyICS4dAuph5o379C1czP39Te8D9w7ukB/gkLKT+Q=" + "value": "dkoi3U_knzOID6E0gXafjefFyLjTP45RTHVkbKF2pCA-1713813157-1.0.1.1-uU5.vfkfbRks2KYTBsLsdy7BFREGvVimnVqFqZx8Gv69JCdAz9KeAAgBqvmXDljRvhQuQ8IZyXm6Z_Xgrrndog" }, { "domain": ".api.openai.com", @@ -116,13 +116,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "gD0vkwOeRDzQ0lSeNT5OwPKC3r.52Abt49OBUtAo0kE-1708597682240-0.0-604800000" + "value": "lWFbeulUNv.Vi32fnlET74wZIz2vCZ08MjqspZWdSOc-1713813157989-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Thu, 22 Feb 2024 10:28:02 GMT" + "value": "Mon, 22 Apr 2024 19:12:37 GMT" }, { "name": "content-type", @@ -154,7 +154,7 @@ }, { "name": "openai-processing-ms", - "value": "285" + "value": "96" }, { "name": "openai-version", @@ -190,7 +190,7 @@ }, { "name": "x-request-id", - "value": "req_9efb97e141aff0324e9f9995f51be425" + "value": "req_e69081e6226d0a179a503d6761ba1cec" }, { "name": "cf-cache-status", @@ -199,12 +199,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=WbDF2EtunDK9RwRxX89DLO_atDDNL9uWiI6Q9igUlbI-1708597682-1.0-AathLYxhkJeQwWYT2s4L3LdY++n9kbv8RoVR3ZaUfkwqtgqyICS4dAuph5o379C1czP39Te8D9w7ukB/gkLKT+Q=; path=/; expires=Thu, 22-Feb-24 10:58:02 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=dkoi3U_knzOID6E0gXafjefFyLjTP45RTHVkbKF2pCA-1713813157-1.0.1.1-uU5.vfkfbRks2KYTBsLsdy7BFREGvVimnVqFqZx8Gv69JCdAz9KeAAgBqvmXDljRvhQuQ8IZyXm6Z_Xgrrndog; path=/; expires=Mon, 22-Apr-24 19:42:37 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=gD0vkwOeRDzQ0lSeNT5OwPKC3r.52Abt49OBUtAo0kE-1708597682240-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=lWFbeulUNv.Vi32fnlET74wZIz2vCZ08MjqspZWdSOc-1713813157989-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -212,21 +212,21 @@ }, { "name": "cf-ray", - "value": "85968a3629a7bb2b-MXP" + "value": "8787ed2b8fdc6d85-MUC" }, { "name": "alt-svc", "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1179, + "headersSize": 1184, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-02-22T10:28:01.417Z", - "time": 1020, + "startedDateTime": "2024-04-22T19:12:37.615Z", + "time": 746, "timings": { "blocked": -1, "connect": -1, @@ -234,7 +234,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 1020 + "wait": 746 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har index 60a8b7a1..741f77a0 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.26.0" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.26.0" + "value": "4.38.3" }, { "_fromType": "array", @@ -87,22 +87,22 @@ "url": "https://api.openai.com/v1/chat/completions" }, "response": { - "bodySize": 6600, + "bodySize": 6348, "content": { "mimeType": "text/event-stream", - "size": 6600, - "text": "data: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" did\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" break\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" up\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" with\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" the\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" debugger\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Because\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" it\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" could\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" never\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" seem\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" to\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" stay\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" out\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" of\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" data\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-8uLvCB6vgvRtO1HY0lpePWK3BOvAA\",\"object\":\"chat.completion.chunk\",\"created\":1708441326,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_69829325d0\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" + "size": 6348, + "text": "data: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Why\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" did\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Open\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Te\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"lemetry\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" break\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" up\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" with\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" debugger\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" Because\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" it\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" couldn\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"'t\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" handle\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" its\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" constant\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" need\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" for\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" attention\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9GtNcQDztin9fqqz1fg9vdZBvAvcQ\",\"object\":\"chat.completion.chunk\",\"created\":1713813156,\"model\":\"gpt-3.5-turbo-0125\",\"system_fingerprint\":\"fp_c2295e73ad\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-02-20T15:32:07.000Z", + "expires": "2024-04-22T19:42:37.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "uhhZQK0XmWGtlawJ7dfFJhFBeiiiqLGUXROZfn6lc8M-1708441327-1.0-AUo47FLrqvLlHZPhmc1sRH95CXiBewLYiji7VQNaoHiQx0Rsv2cxA5v1LyalmjD/l3R/c+9aNpm4Sjo48Quj6oI=" + "value": "3sQNh1EDHv_f8_SJO5450MnF.8Da4GfZWme6HhXDfGY-1713813157-1.0.1.1-PHmRpy7AcdHl6iZHd_P9uGtQzUHUE0k5fqAjgURW7vzqjk7FK1Jyyxmf44f9CXK8Zk0HAfo._TsaJ2lfY_ElDQ" }, { "domain": ".api.openai.com", @@ -111,13 +111,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "5XZzFLgKa9fOE93S.JR7X.EhqJ3MuUU3YY_oq7cOXEA-1708441327183-0.0-604800000" + "value": "CH8IOd3AzbHKfOB2Ag29ElwofV8jkFIa13o88SbEIMI-1713813157038-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 20 Feb 2024 15:02:07 GMT" + "value": "Mon, 22 Apr 2024 19:12:37 GMT" }, { "name": "content-type", @@ -149,7 +149,7 @@ }, { "name": "openai-processing-ms", - "value": "989" + "value": "101" }, { "name": "openai-version", @@ -185,7 +185,7 @@ }, { "name": "x-request-id", - "value": "req_b5ea831fc741cf5dd170b857c0d04844" + "value": "req_f83e84b6806de2f5df6d8f26aab4f586" }, { "name": "cf-cache-status", @@ -194,12 +194,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=uhhZQK0XmWGtlawJ7dfFJhFBeiiiqLGUXROZfn6lc8M-1708441327-1.0-AUo47FLrqvLlHZPhmc1sRH95CXiBewLYiji7VQNaoHiQx0Rsv2cxA5v1LyalmjD/l3R/c+9aNpm4Sjo48Quj6oI=; path=/; expires=Tue, 20-Feb-24 15:32:07 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=3sQNh1EDHv_f8_SJO5450MnF.8Da4GfZWme6HhXDfGY-1713813157-1.0.1.1-PHmRpy7AcdHl6iZHd_P9uGtQzUHUE0k5fqAjgURW7vzqjk7FK1Jyyxmf44f9CXK8Zk0HAfo._TsaJ2lfY_ElDQ; path=/; expires=Mon, 22-Apr-24 19:42:37 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=5XZzFLgKa9fOE93S.JR7X.EhqJ3MuUU3YY_oq7cOXEA-1708441327183-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=CH8IOd3AzbHKfOB2Ag29ElwofV8jkFIa13o88SbEIMI-1713813157038-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -207,21 +207,21 @@ }, { "name": "cf-ray", - "value": "8587a0eecc5b4bf1-MXP" + "value": "8787ed251c1a6d85-MUC" }, { "name": "alt-svc", "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1179, + "headersSize": 1185, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-02-20T15:02:05.748Z", - "time": 1976, + "startedDateTime": "2024-04-22T19:12:36.576Z", + "time": 954, "timings": { "blocked": -1, "connect": -1, @@ -229,7 +229,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 1976 + "wait": 954 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har index e5da956f..a363e739 100644 --- a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har @@ -33,7 +33,7 @@ { "_fromType": "array", "name": "user-agent", - "value": "OpenAI/JS 4.26.0" + "value": "OpenAI/JS 4.38.3" }, { "_fromType": "array", @@ -43,7 +43,7 @@ { "_fromType": "array", "name": "x-stainless-package-version", - "value": "4.26.0" + "value": "4.38.3" }, { "_fromType": "array", @@ -87,22 +87,22 @@ "url": "https://api.openai.com/v1/completions" }, "response": { - "bodySize": 2940, + "bodySize": 3552, "content": { "mimeType": "text/event-stream", - "size": 2940, - "text": "data: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"\\n\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"Why\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" was\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" the\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" Open\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"Te\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"lemetry\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" API\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" always\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" tired\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"?\\n\\n\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\"Because\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" it was constantly\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-8uLvETKbS7q9YvNCTI73j0hKGgZyL\",\"object\":\"text_completion\",\"created\":1708441328,\"choices\":[{\"text\":\" being\",\"index\":0,\"logprobs\":null,\"finish_reason\":\"length\"}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: [DONE]\n\n" + "size": 3552, + "text": "data: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"\\n\\n\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"Why\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" did\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" the\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" Open\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"Te\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"lemetry\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" developer\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" cross\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" the\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" road\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"?\\n\\n\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"To\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" trace\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" the\",\"index\":0,\"logprobs\":null,\"finish_reason\":null}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\" chicken\",\"index\":0,\"logprobs\":null,\"finish_reason\":\"length\"}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: {\"id\":\"cmpl-9GtNfGrT5iBaXuRQ7YLPbyKQvA10e\",\"object\":\"text_completion\",\"created\":1713813159,\"choices\":[{\"text\":\"\",\"index\":0,\"logprobs\":null,\"finish_reason\":\"length\"}],\"model\":\"gpt-3.5-turbo-instruct\"}\n\ndata: [DONE]\n\n" }, "cookies": [ { "domain": ".api.openai.com", - "expires": "2024-02-20T15:32:08.000Z", + "expires": "2024-04-22T19:42:39.000Z", "httpOnly": true, "name": "__cf_bm", "path": "/", "sameSite": "None", "secure": true, - "value": "0Mumjwq5Km79Ka0njKdepdJi92WrQICRG6vysVVZQuE-1708441328-1.0-AWqG497ATr2kPjTJ8S+vAuZQrmiB+tPFshquvkLYqqq5oTwjDi2EauIk8mao65EOYwWFOnhDMchEweRNe3ahKkY=" + "value": "50n7A676e3p2.TVkFm008dFv8GBpLQLpy.C5LIip_J8-1713813159-1.0.1.1-RrNXPWr6AmbOLrLFWoGEo0chFluiRu5D3WJUzCimrW8TJH5JwbTYccCPJSKGAiXXy_JsrgXqjZ4FSKeH5_X.jA" }, { "domain": ".api.openai.com", @@ -111,13 +111,13 @@ "path": "/", "sameSite": "None", "secure": true, - "value": "sT8DGp_vJJx4Wc3gzxa2K2SeuvfbjwoaEu8PVlbTHPM-1708441328316-0.0-604800000" + "value": "rPoigJoJ_.ByGPjLCceoGMkWOsIyPtAhkn0bxGluvYA-1713813159680-0.0.1.1-604800000" } ], "headers": [ { "name": "date", - "value": "Tue, 20 Feb 2024 15:02:08 GMT" + "value": "Mon, 22 Apr 2024 19:12:39 GMT" }, { "name": "content-type", @@ -149,7 +149,7 @@ }, { "name": "openai-processing-ms", - "value": "245" + "value": "177" }, { "name": "openai-version", @@ -161,31 +161,31 @@ }, { "name": "x-ratelimit-limit-requests", - "value": "3000" + "value": "3500" }, { "name": "x-ratelimit-limit-tokens", - "value": "250000" + "value": "90000" }, { "name": "x-ratelimit-remaining-requests", - "value": "2999" + "value": "3499" }, { "name": "x-ratelimit-remaining-tokens", - "value": "249975" + "value": "89976" }, { "name": "x-ratelimit-reset-requests", - "value": "20ms" + "value": "17ms" }, { "name": "x-ratelimit-reset-tokens", - "value": "5ms" + "value": "16ms" }, { "name": "x-request-id", - "value": "req_5a5bc469260aa196ce9bc72a976d1648" + "value": "req_a6428ee064ebdec41fd90cfddf164dc4" }, { "name": "cf-cache-status", @@ -194,12 +194,12 @@ { "_fromType": "array", "name": "set-cookie", - "value": "__cf_bm=0Mumjwq5Km79Ka0njKdepdJi92WrQICRG6vysVVZQuE-1708441328-1.0-AWqG497ATr2kPjTJ8S+vAuZQrmiB+tPFshquvkLYqqq5oTwjDi2EauIk8mao65EOYwWFOnhDMchEweRNe3ahKkY=; path=/; expires=Tue, 20-Feb-24 15:32:08 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "__cf_bm=50n7A676e3p2.TVkFm008dFv8GBpLQLpy.C5LIip_J8-1713813159-1.0.1.1-RrNXPWr6AmbOLrLFWoGEo0chFluiRu5D3WJUzCimrW8TJH5JwbTYccCPJSKGAiXXy_JsrgXqjZ4FSKeH5_X.jA; path=/; expires=Mon, 22-Apr-24 19:42:39 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "_fromType": "array", "name": "set-cookie", - "value": "_cfuvid=sT8DGp_vJJx4Wc3gzxa2K2SeuvfbjwoaEu8PVlbTHPM-1708441328316-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + "value": "_cfuvid=rPoigJoJ_.ByGPjLCceoGMkWOsIyPtAhkn0bxGluvYA-1713813159680-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" }, { "name": "server", @@ -207,21 +207,21 @@ }, { "name": "cf-ray", - "value": "8587a0fad9dd4bf1-MXP" + "value": "8787ed357a3d6d85-MUC" }, { "name": "alt-svc", "value": "h3=\":443\"; ma=86400" } ], - "headersSize": 1183, + "headersSize": 1188, "httpVersion": "HTTP/1.1", "redirectURL": "", "status": 200, "statusText": "OK" }, - "startedDateTime": "2024-02-20T15:02:07.745Z", - "time": 658, + "startedDateTime": "2024-04-22T19:12:39.199Z", + "time": 625, "timings": { "blocked": -1, "connect": -1, @@ -229,7 +229,7 @@ "receive": 0, "send": 0, "ssl": -1, - "wait": 658 + "wait": 625 } } ], diff --git a/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-tool-calling_1747151373/recording.har b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-tool-calling_1747151373/recording.har new file mode 100644 index 00000000..368b4c2d --- /dev/null +++ b/packages/instrumentation-openai/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-tool-calling_1747151373/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for tool calling", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "806765682f8e519a273e660238bf64a5", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 795, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "795" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "OpenAI/JS 4.38.3" + }, + { + "_fromType": "array", + "name": "x-stainless-lang", + "value": "js" + }, + { + "_fromType": "array", + "name": "x-stainless-package-version", + "value": "4.38.3" + }, + { + "_fromType": "array", + "name": "x-stainless-os", + "value": "MacOS" + }, + { + "_fromType": "array", + "name": "x-stainless-arch", + "value": "arm64" + }, + { + "_fromType": "array", + "name": "x-stainless-runtime", + "value": "node" + }, + { + "_fromType": "array", + "name": "x-stainless-runtime-version", + "value": "v18.17.1" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "api.openai.com" + } + ], + "headersSize": 470, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What's the weather like in Boston?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\n \"celsius\",\n \"fahrenheit\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n }\n }\n ]\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 555, + "content": { + "encoding": "base64", + "mimeType": "application/json", + "size": 555, + "text": "[\"H4sIAAAAAAAAA2xSTY/TMBC951eM5tyipK1oNzfQrhYJ0QtIy0JWketO0oA9NvYEqKr+d5T0I9kKH6zRPL83M298SACw2WIOqHdKtPVmevcoT1+36Vr7B57x56ffa17eu/bBRusznHQMt/lBWi6sN9pZb0gaxydYB1JCnWq2zOarbL5M73rAui2ZjlZ7mS6m6dts\",\"fmbsXKMpYg7fEwCAQ393vfGW/mIO6eSSsRSjqgnz6yMADM50GVQxNlEUC04GUDsW4q5dbo0ZAeKcKbUyZih8OodRPBikjCkX7cJU1fMXtdrH+PzNfNg0v2br9cdRvZP03vcNVS3rqzEj/JrPb4oBICvbc2uSUrchEEv5h5TsKNzIAKAKdWuJpRsBDwUDFGicVp14gTkU+N5FcTyBT+8KLPiIrxSOyf/il3N0vLpuXO2D28QbE7FquIm7MpCK/TBjT5OL6Eu/4/bV2tAHZ72U4n4Sd7Kr2UkUh980gNnqDIoTZUb5NE3ObWLcRyFbVg3XFHxorhtPjsk/AAAA//8DADWF8WXoAgAA\"]" + }, + "cookies": [ + { + "domain": ".api.openai.com", + "expires": "2024-04-22T19:51:50.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "ngU7Y1cR2r7_qisHF4OkQECcgnobC7P60RtfnqRAzlI-1713813710-1.0.1.1-r_Dbj7ydNiEGKv84LzpRQqos.lNuSRwZR.srA.GUuy62YHIMBiVXrZ2Xt.J3orkeC.U8jeBkist3.TFfRtQoWg" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "2S7KEg6dybL88qkS28pINwGoW7H_R6N5sbTWS5synrY-1713813710586-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:21:50 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "keep-alive" + }, + { + "name": "access-control-allow-origin", + "value": "*" + }, + { + "name": "cache-control", + "value": "no-cache, must-revalidate" + }, + { + "name": "openai-model", + "value": "gpt-4-0613" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "1475" + }, + { + "name": "openai-version", + "value": "2020-10-01" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800; includeSubDomains" + }, + { + "name": "x-ratelimit-limit-requests", + "value": "5000" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "80000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "79974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "19ms" + }, + { + "name": "x-request-id", + "value": "req_9d1f1fcced3790e4b1375575e2c049e4" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "__cf_bm=ngU7Y1cR2r7_qisHF4OkQECcgnobC7P60RtfnqRAzlI-1713813710-1.0.1.1-r_Dbj7ydNiEGKv84LzpRQqos.lNuSRwZR.srA.GUuy62YHIMBiVXrZ2Xt.J3orkeC.U8jeBkist3.TFfRtQoWg; path=/; expires=Mon, 22-Apr-24 19:51:50 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "_cfuvid=2S7KEg6dybL88qkS28pINwGoW7H_R6N5sbTWS5synrY-1713813710586-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787faa05e1c921e-MUC" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1200, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:21:48.650Z", + "time": 1918, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 1918 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-openai/src/instrumentation.ts b/packages/instrumentation-openai/src/instrumentation.ts index ef1c2af0..526e5f70 100644 --- a/packages/instrumentation-openai/src/instrumentation.ts +++ b/packages/instrumentation-openai/src/instrumentation.ts @@ -280,6 +280,32 @@ export class OpenAIInstrumentation extends InstrumentationBase { JSON.stringify(message.content); } }); + params.functions?.forEach((func, index) => { + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.name` + ] = func.name; + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.description` + ] = func.description; + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.arguments` + ] = JSON.stringify(func.parameters); + }); + params.tools?.forEach((tool, index) => { + if (!tool.function) { + return; + } + + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.name` + ] = tool.function.name; + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.description` + ] = tool.function.description; + attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.${index}.arguments` + ] = JSON.stringify(tool.function.parameters); + }); } else { attributes[`${SpanAttributes.LLM_PROMPTS}.0.role`] = "user"; if (typeof params.prompt === "string") { @@ -362,6 +388,27 @@ export class OpenAIInstrumentation extends InstrumentationBase { arguments: chunk.choices[0].delta.function_call.arguments, }; } + if (chunk.choices[0]?.delta.tool_calls) { + // I needed to re-build the object so that Typescript will understand that arguments are not null. + result.choices[0].message.tool_calls = []; + for (const toolCall of chunk.choices[0].delta.tool_calls) { + if ( + toolCall.id && + toolCall.type && + toolCall.function?.name && + toolCall.function?.arguments + ) { + result.choices[0].message.tool_calls.push({ + id: toolCall.id, + type: toolCall.type, + function: { + name: toolCall.function.name, + arguments: toolCall.function.arguments, + }, + }); + } + } + } } if (result.choices[0].logprobs?.content) { @@ -574,6 +621,16 @@ export class OpenAIInstrumentation extends InstrumentationBase { choice.message.function_call.arguments, ); } + if (choice.message.tool_calls) { + span.setAttribute( + `${SpanAttributes.LLM_COMPLETIONS}.${index}.function_call.name`, + choice.message.tool_calls[0].function.name, + ); + span.setAttribute( + `${SpanAttributes.LLM_COMPLETIONS}.${index}.function_call.arguments`, + choice.message.tool_calls[0].function.arguments, + ); + } }); } else { result.choices.forEach((choice, index) => { diff --git a/packages/instrumentation-openai/test/instrumentation.test.ts b/packages/instrumentation-openai/test/instrumentation.test.ts index 5d6251f1..b8f4ab05 100644 --- a/packages/instrumentation-openai/test/instrumentation.test.ts +++ b/packages/instrumentation-openai/test/instrumentation.test.ts @@ -162,8 +162,8 @@ describe("Test OpenAI instrumentation", async function () { ); }); - it("should set attributes in span for streaming chat with new API", async () => { - const stream = await openai.beta.chat.completions.stream({ + it.skip("should set attributes in span for streaming chat with new API", async () => { + const stream = openai.beta.chat.completions.stream({ messages: [ { role: "user", content: "Tell me a joke about OpenTelemetry" }, ], @@ -310,4 +310,202 @@ describe("Test OpenAI instrumentation", async function () { assert.ok(event); assert.ok(event.attributes?.["logprobs"]); }); + + it("should set attributes in span for function calling", async () => { + const result = await openai.chat.completions.create({ + model: "gpt-4", + messages: [ + { role: "user", content: "What's the weather like in Boston?" }, + ], + functions: [ + { + name: "get_current_weather", + description: "Get the current weather in a given location", + parameters: { + type: "object", + properties: { + location: { + type: "string", + description: "The city and state, e.g. San Francisco, CA", + }, + unit: { + type: "string", + enum: ["celsius", "fahrenheit"], + }, + }, + required: ["location"], + }, + }, + ], + function_call: "auto", + }); + + const spans = memoryExporter.getFinishedSpans(); + const completionSpan = spans.find((span) => span.name === "openai.chat"); + + assert.ok(result); + assert.ok(completionSpan); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.role`], + "user", + ); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.content`], + "What's the weather like in Boston?", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.name` + ], + "get_current_weather", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.description` + ], + "Get the current weather in a given location", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.arguments` + ], + JSON.stringify({ + type: "object", + properties: { + location: { + type: "string", + description: "The city and state, e.g. San Francisco, CA", + }, + unit: { type: "string", enum: ["celsius", "fahrenheit"] }, + }, + required: ["location"], + }), + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_COMPLETIONS}.0.function_call.name` + ], + "get_current_weather", + ); + assert.deepEqual( + JSON.parse( + completionSpan.attributes[ + `${SpanAttributes.LLM_COMPLETIONS}.0.function_call.arguments` + ]! as string, + ), + { location: "Boston" }, + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.equal( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + 82, + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); + }); + + it("should set attributes in span for tool calling", async () => { + const result = await openai.chat.completions.create({ + model: "gpt-4", + messages: [ + { role: "user", content: "What's the weather like in Boston?" }, + ], + tools: [ + { + type: "function", + function: { + name: "get_current_weather", + description: "Get the current weather in a given location", + parameters: { + type: "object", + properties: { + location: { + type: "string", + description: "The city and state, e.g. San Francisco, CA", + }, + unit: { + type: "string", + enum: ["celsius", "fahrenheit"], + }, + }, + required: ["location"], + }, + }, + }, + ], + }); + + const spans = memoryExporter.getFinishedSpans(); + const completionSpan = spans.find((span) => span.name === "openai.chat"); + + assert.ok(result); + assert.ok(completionSpan); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.role`], + "user", + ); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.content`], + "What's the weather like in Boston?", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.name` + ], + "get_current_weather", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.description` + ], + "Get the current weather in a given location", + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_REQUEST_FUNCTIONS}.0.arguments` + ], + JSON.stringify({ + type: "object", + properties: { + location: { + type: "string", + description: "The city and state, e.g. San Francisco, CA", + }, + unit: { type: "string", enum: ["celsius", "fahrenheit"] }, + }, + required: ["location"], + }), + ); + assert.strictEqual( + completionSpan.attributes[ + `${SpanAttributes.LLM_COMPLETIONS}.0.function_call.name` + ], + "get_current_weather", + ); + assert.deepEqual( + JSON.parse( + completionSpan.attributes[ + `${SpanAttributes.LLM_COMPLETIONS}.0.function_call.arguments` + ]! as string, + ), + { location: "Boston, MA" }, + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.equal( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + 82, + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); + }); });