diff --git a/packages/instrumentation-together/.prettierignore b/packages/instrumentation-together/.prettierignore new file mode 100644 index 00000000..258e27f6 --- /dev/null +++ b/packages/instrumentation-together/.prettierignore @@ -0,0 +1,2 @@ +/dist +/coverage \ No newline at end of file diff --git a/packages/instrumentation-together/CHANGELOG.md b/packages/instrumentation-together/CHANGELOG.md new file mode 100644 index 00000000..d2f9f550 --- /dev/null +++ b/packages/instrumentation-together/CHANGELOG.md @@ -0,0 +1,120 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.12.0](https://github.com/traceloop/openllmetry-js/compare/v0.11.7...v0.12.0) (2025-01-13) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.11.6](https://github.com/traceloop/openllmetry-js/compare/v0.11.5...v0.11.6) (2024-12-16) + +### Bug Fixes + +- **deps:** major, minor and various instrumentation fixes ([0f18865](https://github.com/traceloop/openllmetry-js/commit/0f18865c4270c918f6c0b1bec701dc947353a213)) + +## [0.11.5](https://github.com/traceloop/openllmetry-js/compare/v0.11.4...v0.11.5) (2024-12-11) + +### Bug Fixes + +- **openai:** structured output promise unwrapping exception ([#474](https://github.com/traceloop/openllmetry-js/issues/474)) ([546fd9e](https://github.com/traceloop/openllmetry-js/commit/546fd9e6d05eef98a5db7726e3bce267ab57da18)) + +## [0.11.3](https://github.com/traceloop/openllmetry-js/compare/v0.11.2...v0.11.3) (2024-10-16) + +### Bug Fixes + +- **openai:** streaming tool_call + logging multiple tool_call ([#463](https://github.com/traceloop/openllmetry-js/issues/463)) ([5d5de09](https://github.com/traceloop/openllmetry-js/commit/5d5de09e6d32c36a2775ca36cbb14a18fd22f98d)) + +## [0.11.1](https://github.com/traceloop/openllmetry-js/compare/v0.11.0...v0.11.1) (2024-08-31) + +### Bug Fixes + +- **langchain:** instrument vector DB calls ([#440](https://github.com/traceloop/openllmetry-js/issues/440)) ([c129aae](https://github.com/traceloop/openllmetry-js/commit/c129aaec241b4a87f931c2da0774fed96c5c8068)) + +# [0.11.0](https://github.com/traceloop/openllmetry-js/compare/v0.10.0...v0.11.0) (2024-08-27) + +### Bug Fixes + +- include dist .mjs for packages with modules declared ([#425](https://github.com/traceloop/openllmetry-js/issues/425)) ([4a7ec33](https://github.com/traceloop/openllmetry-js/commit/4a7ec33ca5de6a1ad4ba6364bcff4fff8cb2b664)) + +# [0.10.0](https://github.com/traceloop/openllmetry-js/compare/v0.9.5...v0.10.0) (2024-08-01) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.9.2](https://github.com/traceloop/openllmetry-js/compare/v0.9.1...v0.9.2) (2024-07-17) + +### Bug Fixes + +- added missing tslib dependency ([#369](https://github.com/traceloop/openllmetry-js/issues/369)) ([b20145d](https://github.com/traceloop/openllmetry-js/commit/b20145d13b391737febb5b57e4bc8c66b0f32b95)) + +# [0.9.0](https://github.com/traceloop/openllmetry-js/compare/v0.8.9...v0.9.0) (2024-07-04) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.8.8](https://github.com/traceloop/openllmetry-js/compare/v0.8.7...v0.8.8) (2024-06-16) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.8.6](https://github.com/traceloop/openllmetry-js/compare/v0.8.5...v0.8.6) (2024-06-03) + +### Bug Fixes + +- remove sentry; lower noise for instrumentation errors ([#294](https://github.com/traceloop/openllmetry-js/issues/294)) ([c4e3782](https://github.com/traceloop/openllmetry-js/commit/c4e37829ee40983b29831cb68b0343f993f0a33a)) + +## [0.8.2](https://github.com/traceloop/openllmetry-js/compare/v0.8.1...v0.8.2) (2024-05-07) + +### Bug Fixes + +- **openai:** switched to pure js tiktoken ([#248](https://github.com/traceloop/openllmetry-js/issues/248)) ([9d8805e](https://github.com/traceloop/openllmetry-js/commit/9d8805e20e7814ddf7aefbcd31ecb8c7f928b742)) + +# [0.8.0](https://github.com/traceloop/openllmetry-js/compare/v0.7.0...v0.8.0) (2024-04-29) + +### Features + +- v1 of otel semantic conventions ([#232](https://github.com/traceloop/openllmetry-js/issues/232)) ([8f44173](https://github.com/traceloop/openllmetry-js/commit/8f441733ef7f777c273e6e5594361470b4c7957b)) + +# [0.7.0](https://github.com/traceloop/openllmetry-js/compare/v0.6.1...v0.7.0) (2024-04-22) + +### Bug Fixes + +- **openai:** function + tool calling ([#223](https://github.com/traceloop/openllmetry-js/issues/223)) ([790a2de](https://github.com/traceloop/openllmetry-js/commit/790a2de57bf9c30a8aabe473e5262d2125d7b9b2)) + +## [0.6.1](https://github.com/traceloop/openllmetry-js/compare/v0.6.0...v0.6.1) (2024-04-22) + +### Bug Fixes + +- handle exceptions ([#214](https://github.com/traceloop/openllmetry-js/issues/214)) ([65f9be4](https://github.com/traceloop/openllmetry-js/commit/65f9be4fdcaa40f5bfd6c1fe3edc60910b4af894)) + +# [0.6.0](https://github.com/traceloop/openllmetry-js/compare/v0.5.29...v0.6.0) (2024-04-05) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **openai:** enrich token metrics on streaming requests ([#183](https://github.com/traceloop/openllmetry-js/issues/183)) ([2ef0c13](https://github.com/traceloop/openllmetry-js/commit/2ef0c13f16b050d6f73ea9a5952abd0bbfe8a284)) + +## [0.5.28](https://github.com/traceloop/openllmetry-js/compare/v0.5.27...v0.5.28) (2024-04-02) + +### Bug Fixes + +- **openai-instrumentation:** logprobs reporting using span event ([#172](https://github.com/traceloop/openllmetry-js/issues/172)) ([923df7f](https://github.com/traceloop/openllmetry-js/commit/923df7fdb855bcfb16d9571199129d3eaa527eb8)) + +## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) + +**Note:** Version bump only for package @traceloop/instrumentation-openai + +## [0.5.24](https://github.com/traceloop/openllmetry-js/compare/v0.5.23...v0.5.24) (2024-03-15) + +### Bug Fixes + +- switch to rollup for all instrumentations ([#155](https://github.com/traceloop/openllmetry-js/issues/155)) ([605fb46](https://github.com/traceloop/openllmetry-js/commit/605fb46859dc2424fc933268122fb430cefda9ed)) + +## [0.5.23](https://github.com/traceloop/openllmetry-js/compare/v0.5.22...v0.5.23) (2024-03-15) + +### Bug Fixes + +- log instrumentation patching ([#148](https://github.com/traceloop/openllmetry-js/issues/148)) ([82d82bf](https://github.com/traceloop/openllmetry-js/commit/82d82bf563e950fe66f8e2fe64ce7bde3dba222b)) +- only import types in all instrumentations ([#150](https://github.com/traceloop/openllmetry-js/issues/150)) ([7304563](https://github.com/traceloop/openllmetry-js/commit/7304563d9abcd5acfaeed7e16bea64a7245890c7)) +- use correct versions from package.json ([#154](https://github.com/traceloop/openllmetry-js/issues/154)) ([a095fbc](https://github.com/traceloop/openllmetry-js/commit/a095fbcae3d45bd12a772a4e76ed93e64446e062)) diff --git a/packages/instrumentation-together/README.md b/packages/instrumentation-together/README.md new file mode 100644 index 00000000..190d706b --- /dev/null +++ b/packages/instrumentation-together/README.md @@ -0,0 +1,53 @@ +# OpenTelemetry OpenAI instrumentation for Node.js + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image] + +This module provides automatic instrumentation for [`OpenAI SDK`](https://github.com/openai/openai-node) module, which may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package and is included in the [`@traceloop/node-server-sdk`](https://www.npmjs.com/package/@traceloop/node-server-sdk) bundle. + +If total installation size is not constrained, it is recommended to use the [`@traceloop/node-server-sdk`](https://www.npmjs.com/package/@traceloop/node-server-sdk) bundle for the most seamless instrumentation experience. + +Compatible with OpenTelemetry JS API and SDK `1.0+`. + +## Installation + +```bash +npm install --save @traceloop/instrumentation-openai +``` + +## Supported Versions + +- `>=4.12.1` + +## Usage + +To load a specific plugin, specify it in the registerInstrumentations's configuration: + +```js +const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node"); +const { OpenAIInstrumentation } = require("@traceloop/instrumentation-openai"); +const { registerInstrumentations } = require("@opentelemetry/instrumentation"); + +const provider = new NodeTracerProvider(); +provider.register(); + +registerInstrumentations({ + instrumentations: [new OpenAIInstrumentation()], +}); +``` + +## Useful links + +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us on [Slack][slack-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[slack-url]: https://traceloop.com/slack +[license-url]: https://github.com/traceloop/openllmetry-js/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[npm-url]: https://www.npmjs.com/package/@traceloop/instrumentation-openai +[npm-img]: https://badge.fury.io/js/%40traceloop%2Finstrumentation-openai.svg diff --git a/packages/instrumentation-together/eslint.config.cjs b/packages/instrumentation-together/eslint.config.cjs new file mode 100644 index 00000000..bc173051 --- /dev/null +++ b/packages/instrumentation-together/eslint.config.cjs @@ -0,0 +1,29 @@ +const js = require("@eslint/js"); +const rootConfig = require("../../eslint.config.cjs"); + +const { FlatCompat } = require("@eslint/eslintrc"); + +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +module.exports = [ + { + ignores: ["!**/*", "**/node_modules", "dist/**/*"], + }, + ...rootConfig, + { + files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], + rules: {}, + }, + { + files: ["**/*.ts", "**/*.tsx"], + rules: {}, + }, + { + files: ["**/*.js", "**/*.jsx"], + rules: {}, + }, +]; diff --git a/packages/instrumentation-together/package.json b/packages/instrumentation-together/package.json new file mode 100644 index 00000000..ac06e164 --- /dev/null +++ b/packages/instrumentation-together/package.json @@ -0,0 +1,58 @@ +{ + "name": "@traceloop/instrumentation-together", + "version": "0.12.0", + "description": "Together Instrumentation", + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "repository": "traceloop/openllmetry-js", + "scripts": { + "build": "rollup -c", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "test": "ts-mocha -p tsconfig.json 'test/**/*.test.ts' --timeout 20000" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "tracing", + "together" + ], + "author": "Traceloop", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.mjs", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "doc", + "LICENSE", + "README.md", + "package.json" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@opentelemetry/core": "^1.29.0", + "@opentelemetry/instrumentation": "^0.56.0", + "@opentelemetry/semantic-conventions": "^1.28.0", + "@traceloop/ai-semantic-conventions": "^0.12.0", + "js-tiktoken": "^1.0.15", + "tslib": "^2.8.1" + }, + "devDependencies": { + "@pollyjs/adapter-node-http": "^6.0.6", + "@pollyjs/core": "^6.0.6", + "@pollyjs/persister-fs": "^6.0.6", + "@types/mocha": "^10.0.10", + "mocha": "^10.8.2", + "together-ai": "^0.13.0", + "ts-mocha": "^10.0.0" + }, + "homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-openai", + "gitHead": "ef1e70d6037f7b5c061056ef2be16e3f55f02ed5" +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har new file mode 100644 index 00000000..1e8f6e80 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-chat-completion_1028826680/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should emit logprobs span event for chat completion", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "2ead3a029e620e58580faf3ea60f891e", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 159, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "159" + }, + { + "_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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\",\n \"logprobs\": true\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 1147, + "content": { + "encoding": "base64", + "mimeType": "application/json", + "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-04-22T19:42:40.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "3S7nFjQIeVqiriw6xIQiXnrh5rNZGFk24qbLEosQImk-1713813160-1.0.1.1-A6uQAPUGKB0lMQ6lF.vwP3Dpgaa83WwhlZ0voEImwl3uAQmmYxkOou_a0wtblhj_6bd_CgTNgyYrVfhnSCOfCA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "kbUq6yDBUrJ.tFnbx3NklUCqY.1oT7.eEDORno5hrYA-1713813160752-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:40 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-3.5-turbo-0125" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "657" + }, + { + "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": "160000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "159974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "9ms" + }, + { + "name": "x-request-id", + "value": "req_829d9c57bfc8c994a6d6f2b07b1a31c5" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=kbUq6yDBUrJ.tFnbx3NklUCqY.1oT7.eEDORno5hrYA-1713813160752-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed3969e26d85-MUC" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1208, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:39.832Z", + "time": 901, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 901 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har new file mode 100644 index 00000000..aa7034d8 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-emit-logprobs-span-event-for-stream-chat-completion_2713905208/recording.har @@ -0,0 +1,239 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should emit logprobs span event for stream chat completion", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "3574f48515a0df2b90cb3ff02a5b20b4", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 177, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "177" + }, + { + "_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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\",\n \"logprobs\": true,\n \"stream\": true\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 8439, + "content": { + "mimeType": "text/event-stream", + "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-04-22T19:42:41.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "IvxGWemz.5Jwf1cgeGFExmv4X71ZJgqBTZo6Ws5Rdds-1713813161-1.0.1.1-H.NKYWAKbPRQQD5z8kx6kRLTujnbmh0tgo0414TIQTeesswMV3XFIXzO_A6QHZ69qcYciPeVvveDqKhzP7aWSA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "0fF0ycXWpvqZTZNZqzOtzIEKs1c5LVBwtBGsgzQLSQg-1713813161316-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:41 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream" + }, + { + "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-3.5-turbo-0125" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "289" + }, + { + "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": "160000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "159974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "9ms" + }, + { + "name": "x-request-id", + "value": "req_0e578659002bdfe62b6ad1fb8898cece" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=0fF0ycXWpvqZTZNZqzOtzIEKs1c5LVBwtBGsgzQLSQg-1713813161316-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed3f1cb96d85-MUC" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1185, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:40.742Z", + "time": 953, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 953 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har new file mode 100644 index 00000000..e02a62de --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-chat_1427850401/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for chat", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "80b48c70cae76a3c38b9af59d5273e33", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 139, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "139" + }, + { + "_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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\"\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 531, + "content": { + "encoding": "base64", + "mimeType": "application/json", + "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-04-22T19:42:36.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "q5OuIvnhFhBGbpH55TzvYmYDVL3Ag4OF31.WArF_pkQ-1713813156-1.0.1.1-OLd7nKQHw8M9GgsXj0VJxUGOGnhR5VxxBpPo6zyJGPmoYGSZ1F4Sf0SkLe_z2kLUo9IiHU.N3o27X9ONfHhnkA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "1MX6eJy_DiemEOP67xXiY1f3nOw7C0e1VMP.eDQoHk4-1713813156569-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:36 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-3.5-turbo-0125" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "1012" + }, + { + "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": "160000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "159974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "9ms" + }, + { + "name": "x-request-id", + "value": "req_9365d7f94c8394b14f1d0ef06044af37" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=1MX6eJy_DiemEOP67xXiY1f3nOw7C0e1VMP.eDQoHk4-1713813156569-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed1c9e796d85-MUC" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1209, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:35.100Z", + "time": 1455, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 1455 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har new file mode 100644 index 00000000..3323391b --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-completion_322013537/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for completion", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "d406d1fae291f637f37b800f62640320", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 89, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "89" + }, + { + "_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": 464, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"prompt\": \"Tell me a joke about OpenTelemetry\",\n \"model\": \"gpt-3.5-turbo-instruct\"\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/completions" + }, + "response": { + "bodySize": 415, + "content": { + "encoding": "base64", + "mimeType": "application/json", + "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-04-22T19:42:39.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "oSwViHMWIbzf2TOfTqGF.fxTV.HcQjZcARokCHHBSgs-1713813159-1.0.1.1-v2mBZqcpP2HBsJAVlPZMIs7fPl0aa6R5b8bDIaqsRUCnAdrzryjr.uPqEOLzuVkKWx8FhiX7uVXF7BWjmTo9vQ" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "sJm0sCm3f8I6d4lccwweXIJHTYJq8bEqK3Zpwls8eig-1713813159214-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:39 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-3.5-turbo-instruct" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "472" + }, + { + "name": "openai-version", + "value": "2020-10-01" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800; includeSubDomains" + }, + { + "name": "x-ratelimit-limit-requests", + "value": "3500" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "90000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "3499" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "89976" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "17ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "16ms" + }, + { + "name": "x-request-id", + "value": "req_901b97e572d5abbc6ec84fca87839e11" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=sJm0sCm3f8I6d4lccwweXIJHTYJq8bEqK3Zpwls8eig-1713813159214-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed3068ad6d85-MUC" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1211, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:38.391Z", + "time": 801, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 801 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-function-calling_1703714575/recording.har b/packages/instrumentation-together/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-together/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-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har new file mode 100644 index 00000000..1c995235 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat-with-new-API_1429213105/recording.har @@ -0,0 +1,244 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for streaming chat with new API", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "071751fc94b225cca973561463d59f83", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 157, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "157" + }, + { + "_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": "x-stainless-helper-method", + "value": "stream" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "api.openai.com" + } + ], + "headersSize": 505, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\",\n \"stream\": true\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 5300, + "content": { + "mimeType": "text/event-stream", + "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-04-22T19:42:37.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "dkoi3U_knzOID6E0gXafjefFyLjTP45RTHVkbKF2pCA-1713813157-1.0.1.1-uU5.vfkfbRks2KYTBsLsdy7BFREGvVimnVqFqZx8Gv69JCdAz9KeAAgBqvmXDljRvhQuQ8IZyXm6Z_Xgrrndog" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "lWFbeulUNv.Vi32fnlET74wZIz2vCZ08MjqspZWdSOc-1713813157989-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:37 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream" + }, + { + "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-3.5-turbo-0125" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "96" + }, + { + "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": "160000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "159974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "9ms" + }, + { + "name": "x-request-id", + "value": "req_e69081e6226d0a179a503d6761ba1cec" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=lWFbeulUNv.Vi32fnlET74wZIz2vCZ08MjqspZWdSOc-1713813157989-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed2b8fdc6d85-MUC" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1184, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:37.615Z", + "time": 746, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 746 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har new file mode 100644 index 00000000..741f77a0 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har @@ -0,0 +1,239 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for streaming chat", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "071751fc94b225cca973561463d59f83", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 157, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "157" + }, + { + "_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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"gpt-3.5-turbo\",\n \"stream\": true\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/chat/completions" + }, + "response": { + "bodySize": 6348, + "content": { + "mimeType": "text/event-stream", + "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-04-22T19:42:37.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "3sQNh1EDHv_f8_SJO5450MnF.8Da4GfZWme6HhXDfGY-1713813157-1.0.1.1-PHmRpy7AcdHl6iZHd_P9uGtQzUHUE0k5fqAjgURW7vzqjk7FK1Jyyxmf44f9CXK8Zk0HAfo._TsaJ2lfY_ElDQ" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "CH8IOd3AzbHKfOB2Ag29ElwofV8jkFIa13o88SbEIMI-1713813157038-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:37 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream" + }, + { + "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-3.5-turbo-0125" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "101" + }, + { + "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": "160000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "4999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "159974" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "12ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "9ms" + }, + { + "name": "x-request-id", + "value": "req_f83e84b6806de2f5df6d8f26aab4f586" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=CH8IOd3AzbHKfOB2Ag29ElwofV8jkFIa13o88SbEIMI-1713813157038-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed251c1a6d85-MUC" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1185, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:36.576Z", + "time": 954, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 954 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har new file mode 100644 index 00000000..a363e739 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-streaming-completion_1484001317/recording.har @@ -0,0 +1,239 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set attributes in span for streaming completion", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "f36e65259317eae792f4a8b2474cb8b6", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 107, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "107" + }, + { + "_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": 465, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"prompt\": \"Tell me a joke about OpenTelemetry\",\n \"model\": \"gpt-3.5-turbo-instruct\",\n \"stream\": true\n}" + }, + "queryString": [], + "url": "https://api.openai.com/v1/completions" + }, + "response": { + "bodySize": 3552, + "content": { + "mimeType": "text/event-stream", + "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-04-22T19:42:39.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "50n7A676e3p2.TVkFm008dFv8GBpLQLpy.C5LIip_J8-1713813159-1.0.1.1-RrNXPWr6AmbOLrLFWoGEo0chFluiRu5D3WJUzCimrW8TJH5JwbTYccCPJSKGAiXXy_JsrgXqjZ4FSKeH5_X.jA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "rPoigJoJ_.ByGPjLCceoGMkWOsIyPtAhkn0bxGluvYA-1713813159680-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Mon, 22 Apr 2024 19:12:39 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream" + }, + { + "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-3.5-turbo-instruct" + }, + { + "name": "openai-organization", + "value": "traceloop" + }, + { + "name": "openai-processing-ms", + "value": "177" + }, + { + "name": "openai-version", + "value": "2020-10-01" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800; includeSubDomains" + }, + { + "name": "x-ratelimit-limit-requests", + "value": "3500" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "90000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "3499" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "89976" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "17ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "16ms" + }, + { + "name": "x-request-id", + "value": "req_a6428ee064ebdec41fd90cfddf164dc4" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "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=rPoigJoJ_.ByGPjLCceoGMkWOsIyPtAhkn0bxGluvYA-1713813159680-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8787ed357a3d6d85-MUC" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 1188, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-04-22T19:12:39.199Z", + "time": 625, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 625 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-attributes-in-span-for-tool-calling_1747151373/recording.har b/packages/instrumentation-together/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-together/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-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-function_call-attributes-in-span-for-stream-completion-when-multiple-tools-cal_2278551756/recording.har b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-function_call-attributes-in-span-for-stream-completion-when-multiple-tools-cal_2278551756/recording.har new file mode 100644 index 00000000..93e4bf52 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-OpenAI-instrumentation_1770406427/should-set-function_call-attributes-in-span-for-stream-completion-when-multiple-tools-cal_2278551756/recording.har @@ -0,0 +1,231 @@ +{ + "log": { + "_recordingName": "Test OpenAI instrumentation/should set function_call attributes in span for stream completion when multiple tools called", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "4e7f1c094bf406a3975b24c0c8857547", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 1516, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "1516" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "OpenAI/JS 4.57.0" + }, + { + "_fromType": "array", + "name": "x-stainless-lang", + "value": "js" + }, + { + "_fromType": "array", + "name": "x-stainless-package-version", + "value": "4.57.0" + }, + { + "_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": "v22.1.0" + }, + { + "_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-4o-mini\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What's the weather today in Boston and what will the weather be tomorrow in Chicago?\"\n }\n ],\n \"stream\": true,\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 \"type\": \"function\",\n \"function\": {\n \"name\": \"get_tomorrow_weather\",\n \"description\": \"Get tomorrow's 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": 5057, + "content": { + "mimeType": "text/event-stream; charset=utf-8", + "size": 5057, + "text": "data: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":null},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"call_5LSV532rbNrhEKj3XddxLXKb\",\"type\":\"function\",\"function\":{\"name\":\"get_current_weather\",\"arguments\":\"\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"{\\\"lo\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"catio\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"n\\\": \\\"B\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"osto\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"n, MA\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"function\":{\"arguments\":\"\\\"}\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"id\":\"call_8rndUDfjLo174WcwdN7aT7mP\",\"type\":\"function\",\"function\":{\"name\":\"get_tomorrow_weather\",\"arguments\":\"\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"{\\\"lo\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"catio\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"n\\\": \\\"C\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"hica\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"go, I\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":1,\"function\":{\"arguments\":\"L\\\"}\"}}]},\"logprobs\":null,\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-AFzJUI0700ButGSyUudPGR9IqmGJi\",\"object\":\"chat.completion.chunk\",\"created\":1728373972,\"model\":\"gpt-4o-mini-2024-07-18\",\"system_fingerprint\":\"fp_f85bea6784\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"tool_calls\"}]}\n\ndata: [DONE]\n\n" + }, + "cookies": [ + { + "domain": ".api.openai.com", + "expires": "2024-10-08T08:22:52.000Z", + "httpOnly": true, + "name": "__cf_bm", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "7VLzjD6bk2vl3dQ1buulluBXUcZWRHRf3FMpMkNfDe4-1728373972-1.0.1.1-M5XcPulIjIntr0YG3dvI4hnwTDHLaXKHuLZd_JUTOH40kvNyQnhrPvm2PB12Tf7rR.E_D7F80cPaEEHKxli0SA" + }, + { + "domain": ".api.openai.com", + "httpOnly": true, + "name": "_cfuvid", + "path": "/", + "sameSite": "None", + "secure": true, + "value": "M4JyAwhhEaoDpYpUXniLhAW_YlQUIJCcsDEx1ZsVvTs-1728373972937-0.0.1.1-604800000" + } + ], + "headers": [ + { + "name": "date", + "value": "Tue, 08 Oct 2024 07:52:52 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream; charset=utf-8" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "keep-alive" + }, + { + "name": "access-control-expose-headers", + "value": "X-Request-ID" + }, + { + "name": "openai-organization", + "value": "trubrics" + }, + { + "name": "openai-processing-ms", + "value": "625" + }, + { + "name": "openai-version", + "value": "2020-10-01" + }, + { + "name": "strict-transport-security", + "value": "max-age=31536000; includeSubDomains; preload" + }, + { + "name": "x-ratelimit-limit-requests", + "value": "10000" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "10000000" + }, + { + "name": "x-ratelimit-remaining-requests", + "value": "9999" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "9999961" + }, + { + "name": "x-ratelimit-reset-requests", + "value": "6ms" + }, + { + "name": "x-ratelimit-reset-tokens", + "value": "0s" + }, + { + "name": "x-request-id", + "value": "req_a89738719c34e11ea192e73a5497d00a" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "__cf_bm=7VLzjD6bk2vl3dQ1buulluBXUcZWRHRf3FMpMkNfDe4-1728373972-1.0.1.1-M5XcPulIjIntr0YG3dvI4hnwTDHLaXKHuLZd_JUTOH40kvNyQnhrPvm2PB12Tf7rR.E_D7F80cPaEEHKxli0SA; path=/; expires=Tue, 08-Oct-24 08:22:52 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "_fromType": "array", + "name": "set-cookie", + "value": "_cfuvid=M4JyAwhhEaoDpYpUXniLhAW_YlQUIJCcsDEx1ZsVvTs-1728373972937-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "cf-ray", + "value": "8cf48dcd0a786fdb-CDG" + } + ], + "headersSize": 1150, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-10-08T07:52:51.703Z", + "time": 1328, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 1328 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-chat_1427850401/recording.har b/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-chat_1427850401/recording.har new file mode 100644 index 00000000..4ae21982 --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-chat_1427850401/recording.har @@ -0,0 +1,227 @@ +{ + "log": { + "_recordingName": "Test Together AI instrumentation/should set attributes in span for chat", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "86ffcdda66bcf9b15460f7f1f623984d", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 205, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "205" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "Together/JS 0.13.0" + }, + { + "_fromType": "array", + "name": "x-stainless-lang", + "value": "js" + }, + { + "_fromType": "array", + "name": "x-stainless-package-version", + "value": "0.13.0" + }, + { + "_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": "x-stainless-retry-count", + "value": "0" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "api.together.xyz" + } + ], + "headersSize": 503, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"temperature\": 0.7,\n \"max_tokens\": 100\n}" + }, + "queryString": [], + "url": "https://api.together.xyz/v1/chat/completions" + }, + "response": { + "bodySize": 527, + "content": { + "encoding": "base64", + "mimeType": "application/json; charset=utf-8", + "size": 527, + "text": "[\"H4sIAAAAAAAAA1RSwU7jMBC99ysGXwBpyyYlkKYXJG4cVlyQ9oBQNXGnjRfHE3kmpRHi31dOSrt7saz3Zt4bv/HnDMC4jVmBqfICcywpr+stIlbmR+K4/kNWE28b1BvLbedJHYeJtpFQKfXnZZFl2bIoFiPR8oZ8amudaESP7ucvd0i3+fJQPs6fgmjsrc732U0+aXWR2y5Zvb5N2g07S5KAGQDA53gCmK0LTpp1JBQOyYNYRomRFZrmKRaL+/LuflmVVbm8y8osy041nndd5Dpph977E+7Chg5mBefKlkRwR2Z1sgcwkX1CDIo4UQx6ck9jc1AKY2Twuxlgw+FS4YOA9hShIYwgZCMpCaACwnNH4YU8taRxAMthTyEl/ACPZLGXqXPgQOAElBnqXgbQiNaF3QVcPV16D0IE7SDkt8C9Xv87kTL7tUXvxyzfjsTX7Puc4u7/e+dxG2vldwoy7ndSNOcvcCZvF0dSWdGf8aKaJYuvvwAAAP//\",\"AwBd/wi/ZwIAAA==\"]" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Wed, 19 Feb 2025 23:40:43 GMT" + }, + { + "name": "content-type", + "value": "application/json; charset=utf-8" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "keep-alive" + }, + { + "name": "cf-ray", + "value": "914a1a7e1bbfaaa9-SJC" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "name": "retry-after", + "value": "2" + }, + { + "name": "access-control-allow-origin", + "value": "*" + }, + { + "name": "etag", + "value": "W/\"267-oXwZS36cQLj4wx0ql1s2nzQ8CLw\"" + }, + { + "name": "strict-transport-security", + "value": "max-age=15552000; includeSubDomains" + }, + { + "name": "x-api-call-end", + "value": "2025-02-19T23:40:43.307Z" + }, + { + "name": "x-api-call-start", + "value": "2025-02-19T23:40:42.643Z" + }, + { + "name": "x-api-received", + "value": "2025-02-19T23:40:42.618Z" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-inference-version", + "value": "v2" + }, + { + "name": "x-ratelimit", + "value": "false" + }, + { + "name": "x-ratelimit-limit", + "value": "10" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "3000" + }, + { + "name": "x-ratelimit-remaining", + "value": "19" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "3000" + }, + { + "name": "x-ratelimit-reset", + "value": "2" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "content-encoding", + "value": "gzip" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 792, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-02-19T23:40:42.451Z", + "time": 847, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 847 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har b/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har new file mode 100644 index 00000000..c467077c --- /dev/null +++ b/packages/instrumentation-together/recordings/Test-Together-AI-instrumentation_455929487/should-set-attributes-in-span-for-streaming-chat_72904453/recording.har @@ -0,0 +1,218 @@ +{ + "log": { + "_recordingName": "Test Together AI instrumentation/should set attributes in span for streaming chat", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.6" + }, + "entries": [ + { + "_id": "babb8ce30a876ff6793f68a7b8c35f75", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 223, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-length", + "value": "223" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "Together/JS 0.13.0" + }, + { + "_fromType": "array", + "name": "x-stainless-lang", + "value": "js" + }, + { + "_fromType": "array", + "name": "x-stainless-package-version", + "value": "0.13.0" + }, + { + "_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": "x-stainless-retry-count", + "value": "0" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "name": "host", + "value": "api.together.xyz" + } + ], + "headersSize": 503, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Tell me a joke about OpenTelemetry\"\n }\n ],\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"temperature\": 0.7,\n \"max_tokens\": 100,\n \"stream\": true\n}" + }, + "queryString": [], + "url": "https://api.together.xyz/v1/chat/completions" + }, + "response": { + "bodySize": 18910, + "content": { + "mimeType": "text/event-stream;charset=utf-8", + "size": 18910, + "text": "data: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" Why\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":4315,\"role\":\"assistant\",\"content\":\" Why\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" don\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":949,\"role\":\"assistant\",\"content\":\" don\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"'\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28742,\"role\":\"assistant\",\"content\":\"'\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"t\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28707,\"role\":\"assistant\",\"content\":\"t\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" secrets\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":19376,\"role\":\"assistant\",\"content\":\" secrets\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" tell\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":1912,\"role\":\"assistant\",\"content\":\" tell\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" Open\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":5629,\"role\":\"assistant\",\"content\":\" Open\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"Tele\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":21468,\"role\":\"assistant\",\"content\":\"Tele\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"metry\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":16641,\"role\":\"assistant\",\"content\":\"metry\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" where\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":970,\"role\":\"assistant\",\"content\":\" where\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" they\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":590,\"role\":\"assistant\",\"content\":\" they\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"'\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28742,\"role\":\"assistant\",\"content\":\"'\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"re\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":267,\"role\":\"assistant\",\"content\":\"re\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" going\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":1404,\"role\":\"assistant\",\"content\":\" going\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"?\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28804,\"role\":\"assistant\",\"content\":\"?\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"\\n\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":13,\"role\":\"assistant\",\"content\":\"\\n\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"\\n\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":13,\"role\":\"assistant\",\"content\":\"\\n\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"Because\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":17098,\"role\":\"assistant\",\"content\":\"Because\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" they\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":590,\"role\":\"assistant\",\"content\":\" they\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"'\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28742,\"role\":\"assistant\",\"content\":\"'\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"re\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":267,\"role\":\"assistant\",\"content\":\"re\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" afraid\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":8526,\"role\":\"assistant\",\"content\":\" afraid\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" of\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":302,\"role\":\"assistant\",\"content\":\" of\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" being\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":1250,\"role\":\"assistant\",\"content\":\" being\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" tr\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":467,\"role\":\"assistant\",\"content\":\" tr\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"aced\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":2701,\"role\":\"assistant\",\"content\":\"aced\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"!\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28808,\"role\":\"assistant\",\"content\":\"!\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"\\n\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":13,\"role\":\"assistant\",\"content\":\"\\n\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"\\n\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":13,\"role\":\"assistant\",\"content\":\"\\n\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"(\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28732,\"role\":\"assistant\",\"content\":\"(\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"I\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28737,\"role\":\"assistant\",\"content\":\"I\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"'\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28742,\"role\":\"assistant\",\"content\":\"'\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"m\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28719,\"role\":\"assistant\",\"content\":\"m\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" sorry\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":7371,\"role\":\"assistant\",\"content\":\" sorry\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\",\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28725,\"role\":\"assistant\",\"content\":\",\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" I\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":315,\"role\":\"assistant\",\"content\":\" I\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" couldn\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":3481,\"role\":\"assistant\",\"content\":\" couldn\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"'\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28742,\"role\":\"assistant\",\"content\":\"'\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"t\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28707,\"role\":\"assistant\",\"content\":\"t\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" resist\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":14905,\"role\":\"assistant\",\"content\":\" resist\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" the\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":272,\"role\":\"assistant\",\"content\":\" the\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" pun\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":5704,\"role\":\"assistant\",\"content\":\" pun\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\".\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28723,\"role\":\"assistant\",\"content\":\".\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" Open\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":5629,\"role\":\"assistant\",\"content\":\" Open\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"Tele\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":21468,\"role\":\"assistant\",\"content\":\"Tele\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"metry\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":16641,\"role\":\"assistant\",\"content\":\"metry\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" is\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":349,\"role\":\"assistant\",\"content\":\" is\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" an\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":396,\"role\":\"assistant\",\"content\":\" an\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" amazing\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":6821,\"role\":\"assistant\",\"content\":\" amazing\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" open\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":1565,\"role\":\"assistant\",\"content\":\" open\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"-\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28733,\"role\":\"assistant\",\"content\":\"-\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"source\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":1394,\"role\":\"assistant\",\"content\":\"source\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" project\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":2488,\"role\":\"assistant\",\"content\":\" project\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" for\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":354,\"role\":\"assistant\",\"content\":\" for\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" distributed\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":4832,\"role\":\"assistant\",\"content\":\" distributed\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" tracing\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":28469,\"role\":\"assistant\",\"content\":\" tracing\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" and\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":304,\"role\":\"assistant\",\"content\":\" and\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\" monitoring\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":16882,\"role\":\"assistant\",\"content\":\" monitoring\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\".)\",\"logprobs\":null,\"finish_reason\":null,\"seed\":null,\"delta\":{\"token_id\":2974,\"role\":\"assistant\",\"content\":\".)\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":null}\n\ndata: {\"id\":\"914a1a830a40aaa9\",\"object\":\"chat.completion.chunk\",\"created\":1740008443,\"choices\":[{\"index\":0,\"text\":\"\",\"logprobs\":null,\"finish_reason\":\"eos\",\"seed\":8886054274000685000,\"delta\":{\"token_id\":2,\"role\":\"assistant\",\"content\":\"\",\"tool_calls\":null}}],\"model\":\"mistralai/Mixtral-8x7B-Instruct-v0.1\",\"usage\":{\"prompt_tokens\":17,\"completion_tokens\":60,\"total_tokens\":77}}\n\ndata: [DONE]\n\n" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Wed, 19 Feb 2025 23:40:43 GMT" + }, + { + "name": "content-type", + "value": "text/event-stream;charset=utf-8" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "keep-alive" + }, + { + "name": "cf-ray", + "value": "914a1a830a40aaa9-SJC" + }, + { + "name": "cf-cache-status", + "value": "DYNAMIC" + }, + { + "name": "retry-after", + "value": "1" + }, + { + "name": "access-control-allow-origin", + "value": "*" + }, + { + "name": "cache-control", + "value": "no-cache, no-transform" + }, + { + "name": "strict-transport-security", + "value": "max-age=15552000; includeSubDomains" + }, + { + "name": "x-api-call-start", + "value": "2025-02-19T23:40:43.418Z" + }, + { + "name": "x-api-received", + "value": "2025-02-19T23:40:43.410Z" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "x-inference-version", + "value": "v2" + }, + { + "name": "x-ratelimit", + "value": "false" + }, + { + "name": "x-ratelimit-limit", + "value": "10" + }, + { + "name": "x-ratelimit-limit-tokens", + "value": "3000" + }, + { + "name": "x-ratelimit-remaining", + "value": "18" + }, + { + "name": "x-ratelimit-remaining-tokens", + "value": "2951" + }, + { + "name": "x-ratelimit-reset", + "value": "1" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "server", + "value": "cloudflare" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=86400" + } + ], + "headersSize": 722, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-02-19T23:40:43.310Z", + "time": 763, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 763 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/instrumentation-together/rollup.config.js b/packages/instrumentation-together/rollup.config.js new file mode 100644 index 00000000..962f7f79 --- /dev/null +++ b/packages/instrumentation-together/rollup.config.js @@ -0,0 +1,36 @@ +const dts = require("rollup-plugin-dts"); +const typescript = require("@rollup/plugin-typescript"); +const json = require("@rollup/plugin-json"); + +const name = require("./package.json").main.replace(/\.js$/, ""); + +const bundle = (config) => ({ + ...config, + input: "src/index.ts", + external: (id) => !/^[./]/.test(id), +}); + +exports.default = [ + bundle({ + plugins: [typescript.default(), json.default()], + output: [ + { + file: `${name}.js`, + format: "cjs", + sourcemap: true, + }, + { + file: `${name}.mjs`, + format: "es", + sourcemap: true, + }, + ], + }), + bundle({ + plugins: [dts.default()], + output: { + file: `${name}.d.ts`, + format: "es", + }, + }), +]; diff --git a/packages/instrumentation-together/src/index.ts b/packages/instrumentation-together/src/index.ts new file mode 100644 index 00000000..ec28d1d9 --- /dev/null +++ b/packages/instrumentation-together/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Traceloop + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from "./instrumentation"; +export * from "./types"; diff --git a/packages/instrumentation-together/src/instrumentation.ts b/packages/instrumentation-together/src/instrumentation.ts new file mode 100644 index 00000000..98adb60b --- /dev/null +++ b/packages/instrumentation-together/src/instrumentation.ts @@ -0,0 +1,191 @@ +/* + * Copyright Traceloop + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + InstrumentationBase, + InstrumentationNodeModuleDefinition, +} from "@opentelemetry/instrumentation"; +import { SpanKind, SpanStatusCode, context, trace } from "@opentelemetry/api"; +import { SemanticAttributes } from "@opentelemetry/semantic-conventions"; +import { SpanAttributes } from "@traceloop/ai-semantic-conventions"; +import { TogetherInstrumentationConfig } from "./types"; + +export class TogetherInstrumentation extends InstrumentationBase { + constructor(config: TogetherInstrumentationConfig = {}) { + super("@traceloop/instrumentation-together", "0.1.0", config); + } + + protected init(): InstrumentationNodeModuleDefinition[] { + const module = new InstrumentationNodeModuleDefinition( + "together-ai", + ["*"], + (moduleExports) => { + this._diag.debug("Applying patch for together-ai"); + const together = moduleExports; + + if (together?.Together?.prototype) { + const client = new together.Together({ apiKey: "test" }); + this._wrap( + Object.getPrototypeOf(client.chat.completions), + "create", + this._patchChatCompletions(), + ); + } + + return moduleExports; + }, + (moduleExports) => { + if (moduleExports?.Together?.prototype) { + const client = new moduleExports.Together({ apiKey: "test" }); + this._unwrap( + Object.getPrototypeOf(client.chat.completions), + "create", + ); + } + }, + ); + + return [module]; + } + + private _patchChatCompletions() { + const instrumentation = this; + + return function (original: (...args: unknown[]) => Promise) { + return async function wrapped(this: unknown, ...args: unknown[]) { + const params = args[0] || {}; + + const span = instrumentation.tracer.startSpan("together.chat", { + kind: SpanKind.CLIENT, + attributes: { + [SemanticAttributes.HTTP_METHOD]: "POST", + [SemanticAttributes.HTTP_URL]: + "https://api.together.xyz/v1/chat/completions", + [SpanAttributes.LLM_SYSTEM]: "together", + [SpanAttributes.LLM_REQUEST_MODEL]: (params as any).model, + [SpanAttributes.LLM_REQUEST_MAX_TOKENS]: (params as any).max_tokens, + [SpanAttributes.LLM_REQUEST_TEMPERATURE]: (params as any) + .temperature, + [SpanAttributes.LLM_REQUEST_TOP_P]: (params as any).top_p, + [SpanAttributes.LLM_FREQUENCY_PENALTY]: (params as any) + .frequency_penalty, + [SpanAttributes.LLM_PRESENCE_PENALTY]: (params as any) + .presence_penalty, + }, + }); + + // Set prompt attributes + if ((params as any).messages) { + (params as any).messages.forEach((message: any, index: number) => { + span.setAttribute( + `${SpanAttributes.LLM_PROMPTS}.${index}.role`, + message.role, + ); + span.setAttribute( + `${SpanAttributes.LLM_PROMPTS}.${index}.content`, + message.content, + ); + }); + } + + let response; + try { + response = await context.with( + trace.setSpan(context.active(), span), + async () => original.apply(this, args), + ); + + if ((params as any).stream) { + let content = ""; + const streamResponse = response as AsyncIterable; + const originalIterator = streamResponse[Symbol.asyncIterator](); + + const wrappedIterator = { + [Symbol.asyncIterator]() { + return this; + }, + async next() { + const result = await originalIterator.next(); + + if (!result.done) { + const chunk = result.value; + content += chunk.choices[0]?.delta?.content || ""; + + if (chunk.usage) { + span.setAttribute( + `${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`, + chunk.usage.prompt_tokens, + ); + span.setAttribute( + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}`, + chunk.usage.completion_tokens, + ); + span.setAttribute( + `${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`, + chunk.usage.total_tokens, + ); + } + } else { + span.setAttribute( + `${SpanAttributes.LLM_COMPLETIONS}.0.content`, + content, + ); + span.end(); + } + + return result; + }, + }; + + return wrappedIterator; + } else { + if ((response as any).choices?.[0]?.message?.content) { + span.setAttribute( + `${SpanAttributes.LLM_COMPLETIONS}.0.content`, + (response as any).choices[0].message.content, + ); + } + + if ((response as any).usage) { + span.setAttribute( + `${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`, + (response as any).usage.prompt_tokens, + ); + span.setAttribute( + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}`, + (response as any).usage.completion_tokens, + ); + span.setAttribute( + `${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`, + (response as any).usage.total_tokens, + ); + } + + span.end(); + } + } catch (error: any) { + span.setStatus({ + code: SpanStatusCode.ERROR, + message: error?.message, + }); + span.end(); + throw error; + } + + return response; + }; + }; + } +} diff --git a/packages/instrumentation-together/src/types.ts b/packages/instrumentation-together/src/types.ts new file mode 100644 index 00000000..a3b69f6e --- /dev/null +++ b/packages/instrumentation-together/src/types.ts @@ -0,0 +1,40 @@ +/* + * Copyright Traceloop + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { InstrumentationConfig } from "@opentelemetry/instrumentation"; + +export interface OpenAIInstrumentationConfig extends InstrumentationConfig { + /** + * Whether to log prompts, completions and embeddings on traces. + * @default true + */ + traceContent?: boolean; + + /** + * Whether to enrich token information if missing from the trace. + * @default false + */ + enrichTokens?: boolean; + + /** + * A custom logger to log any exceptions that happen during span creation. + */ + exceptionLogger?: (e: Error) => void; +} + +export interface TogetherInstrumentationConfig extends InstrumentationConfig { + enrichTokens?: boolean; +} diff --git a/packages/instrumentation-together/test/instrumentation.test.ts b/packages/instrumentation-together/test/instrumentation.test.ts new file mode 100644 index 00000000..42fb6aad --- /dev/null +++ b/packages/instrumentation-together/test/instrumentation.test.ts @@ -0,0 +1,168 @@ +/* + * Copyright Traceloop + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as assert from "assert"; + +import { context } from "@opentelemetry/api"; +import { AsyncHooksContextManager } from "@opentelemetry/context-async-hooks"; +import { + BasicTracerProvider, + InMemorySpanExporter, + SimpleSpanProcessor, +} from "@opentelemetry/sdk-trace-base"; + +import type * as TogetherModule from "together-ai"; + +import { TogetherInstrumentation } from "../src/instrumentation"; + +import { Polly, setupMocha as setupPolly } from "@pollyjs/core"; +import NodeHttpAdapter from "@pollyjs/adapter-node-http"; +import FSPersister from "@pollyjs/persister-fs"; +import { SpanAttributes } from "@traceloop/ai-semantic-conventions"; + +const memoryExporter = new InMemorySpanExporter(); + +Polly.register(NodeHttpAdapter); +Polly.register(FSPersister); + +describe("Test Together AI instrumentation", async function () { + const provider = new BasicTracerProvider(); + let instrumentation: TogetherInstrumentation; + let contextManager: AsyncHooksContextManager; + let together: TogetherModule.Together; + + setupPolly({ + adapters: ["node-http"], + persister: "fs", + recordIfMissing: process.env.RECORD_MODE === "NEW", + matchRequestsBy: { + headers: false, + }, + }); + + before(async () => { + if (process.env.RECORD_MODE !== "NEW") { + process.env.TOGETHER_API_KEY = "test"; + } + provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); + instrumentation = new TogetherInstrumentation({ enrichTokens: true }); + instrumentation.setTracerProvider(provider); + + const togetherModule = await import("together-ai"); + together = new togetherModule.Together({ + apiKey: process.env.TOGETHER_API_KEY, + }); + }); + + beforeEach(function () { + contextManager = new AsyncHooksContextManager().enable(); + context.setGlobalContextManager(contextManager); + + const { server } = this.polly as Polly; + server.any().on("beforePersist", (_req, recording) => { + recording.request.headers = recording.request.headers.filter( + ({ name }: { name: string }) => name !== "authorization", + ); + }); + }); + + afterEach(async () => { + memoryExporter.reset(); + context.disable(); + }); + + it("should set attributes in span for chat", async () => { + const result = await together.chat.completions.create({ + messages: [ + { role: "user", content: "Tell me a joke about OpenTelemetry" }, + ], + model: "mistralai/Mixtral-8x7B-Instruct-v0.1", + temperature: 0.7, + max_tokens: 100, + }); + + const spans = memoryExporter.getFinishedSpans(); + const completionSpan = spans.find((span) => span.name === "together.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`], + "Tell me a joke about OpenTelemetry", + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); + }); + + it("should set attributes in span for streaming chat", async () => { + const stream = await together.chat.completions.create({ + messages: [ + { role: "user", content: "Tell me a joke about OpenTelemetry" }, + ], + model: "mistralai/Mixtral-8x7B-Instruct-v0.1", + temperature: 0.7, + max_tokens: 100, + stream: true, + }); + + let result = ""; + for await (const chunk of stream) { + result += chunk.choices[0]?.delta?.content || ""; + } + + const spans = memoryExporter.getFinishedSpans(); + const completionSpan = spans.find((span) => span.name === "together.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`], + "Tell me a joke about OpenTelemetry", + ); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_COMPLETIONS}.0.content`], + result, + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); + }); +}); diff --git a/packages/instrumentation-together/tsconfig.json b/packages/instrumentation-together/tsconfig.json new file mode 100644 index 00000000..559aaa89 --- /dev/null +++ b/packages/instrumentation-together/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "." + }, + "files": [], + "include": ["src/**/*.ts", "test/**/*.ts", "package.json"], + "references": [] +}