Skip to content

Commit 9a67b49

Browse files
committed
fix(sdk): patch span attributes for vercel AI users
1 parent 6196816 commit 9a67b49

File tree

17 files changed

+1039
-868
lines changed

17 files changed

+1039
-868
lines changed

package-lock.json

+286-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sample-app/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"run:decorators": "npm run build && node dist/src/sample_decorators.js",
1818
"run:with": "npm run build && node dist/src/sample_with.js",
1919
"run:prompt_mgmt": "npm run build && node dist/src/sample_prompt_mgmt.js",
20+
"run:vercel": "npm run build && node dist/src/sample_vercel_ai.js",
2021
"run:sample_vision": "npm run build && node dist/src/sample_vision_prompt.js",
2122
"run:sample_azure": "npm run build && node dist/src/sample_azure.js",
2223
"run:openai_streaming": "npm run build && node dist/src/sample_openai_streaming.js",
@@ -35,20 +36,22 @@
3536
"node": ">=14"
3637
},
3738
"dependencies": {
39+
"@ai-sdk/openai": "^1.0.10",
3840
"@anthropic-ai/sdk": "^0.32.1",
3941
"@aws-sdk/client-bedrock-runtime": "^3.709.0",
4042
"@azure/openai": "^1.0.0-beta.13",
4143
"@google-cloud/aiplatform": "^3.34.0",
4244
"@google-cloud/vertexai": "^1.9.2",
4345
"@langchain/community": "^0.3.18",
46+
"@llamaindex/openai": "^0.1.44",
4447
"@pinecone-database/pinecone": "^2.2.2",
4548
"@traceloop/node-server-sdk": "*",
49+
"ai": "^4.0.20",
4650
"cheerio": "^1.0.0",
4751
"chromadb": "^1.9.4",
4852
"cohere-ai": "^7.15.0",
4953
"langchain": "^0.3.7",
5054
"llamaindex": "^0.8.28",
51-
"@llamaindex/openai": "^0.1.44",
5255
"openai": "^4.76.2",
5356
"zod": "^3.24.1"
5457
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as traceloop from "@traceloop/node-server-sdk";
2+
import { openai } from "@ai-sdk/openai";
3+
import { generateText } from "ai";
4+
5+
traceloop.initialize({
6+
appName: "sample_vercel_ai",
7+
disableBatch: true,
8+
});
9+
10+
async function chat(question: string) {
11+
return await traceloop.withWorkflow(
12+
{ name: "chat" },
13+
async () => {
14+
const chatCompletion = await generateText({
15+
messages: [{ role: "user", content: question }],
16+
model: openai("gpt-3.5-turbo"),
17+
experimental_telemetry: { isEnabled: true },
18+
});
19+
20+
return chatCompletion.text;
21+
},
22+
{ question },
23+
);
24+
}
25+
26+
chat("What is the capital of France?");

packages/traceloop-sdk/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/traceloop-sdk",
6161
"gitHead": "ef1e70d6037f7b5c061056ef2be16e3f55f02ed5",
6262
"devDependencies": {
63+
"@ai-sdk/openai": "^1.0.10",
64+
"ai": "^4.0.20",
6365
"@anthropic-ai/sdk": "^0.32.1",
6466
"@aws-sdk/client-bedrock-runtime": "^3.709.0",
6567
"@azure/openai": "^1.0.0-beta.13",

packages/traceloop-sdk/recordings/Test-SDK-Decorators_847855269/should-create-a-span-for-workflows-with-input_862263550/output_2041138948/recording.har

-244
This file was deleted.

0 commit comments

Comments
 (0)