Skip to content

Commit 6b1eb68

Browse files
committed
Mount cerebras instrumentation in SDK and add sample
1 parent 3303af9 commit 6b1eb68

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sample-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@anthropic-ai/sdk": "^0.32.1",
4141
"@aws-sdk/client-bedrock-runtime": "^3.709.0",
4242
"@azure/openai": "^1.0.0-beta.13",
43+
"@cerebras/cerebras_cloud_sdk": "^1.29.0",
4344
"@google-cloud/aiplatform": "^3.34.0",
4445
"@google-cloud/vertexai": "^1.9.2",
4546
"@langchain/community": "^0.3.18",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as traceloop from "@traceloop/node-server-sdk";
2+
import { Cerebras } from "@cerebras/cerebras_cloud_sdk";
3+
4+
traceloop.initialize({
5+
appName: "sample_cerebras",
6+
apiKey: process.env.TRACELOOP_API_KEY,
7+
disableBatch: true,
8+
});
9+
const cerebras = new Cerebras({});
10+
11+
async function main() {
12+
const completion = await cerebras.chat.completions.create({
13+
max_tokens: 1024,
14+
model: "llama-3.1-8b",
15+
messages: [
16+
{
17+
role: "user",
18+
content: "How does a court case get to the Supreme Court?",
19+
},
20+
],
21+
});
22+
23+
console.log((completion.choices as any)[0].message.content);
24+
}
25+
26+
main();

packages/traceloop-sdk/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@traceloop/instrumentation-anthropic": "^0.12.0",
4242
"@traceloop/instrumentation-azure": "^0.12.0",
4343
"@traceloop/instrumentation-bedrock": "^0.12.0",
44+
"@traceloop/instrumentation-cerebras": "^0.1.0",
4445
"@traceloop/instrumentation-chromadb": "^0.12.0",
4546
"@traceloop/instrumentation-cohere": "^0.12.0",
4647
"@traceloop/instrumentation-langchain": "^0.12.0",
@@ -65,6 +66,7 @@
6566
"@anthropic-ai/sdk": "^0.32.1",
6667
"@aws-sdk/client-bedrock-runtime": "^3.709.0",
6768
"@azure/openai": "^1.0.0-beta.13",
69+
"@cerebras/cerebras_cloud_sdk": "^1.29.0",
6870
"@google-cloud/aiplatform": "^3.34.0",
6971
"@google-cloud/vertexai": "^1.9.2",
7072
"@pinecone-database/pinecone": "^2.2.2",

packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type * as VectorStoreModule from "@langchain/core/vectorstores";
1717
import type * as llamaindex from "llamaindex";
1818
import type * as chromadb from "chromadb";
1919
import type * as qdrant from "@qdrant/js-client-rest";
20+
import type * as cerebras from "@cerebras/cerebras_cloud_sdk";
2021

2122
/**
2223
* Options for initializing the Traceloop SDK.
@@ -111,6 +112,7 @@ export interface InitializeOptions {
111112
llamaIndex?: typeof llamaindex;
112113
chromadb?: typeof chromadb;
113114
qdrant?: typeof qdrant;
115+
cerebras?: typeof cerebras;
114116
};
115117

116118
/**

packages/traceloop-sdk/src/lib/tracing/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { LangChainInstrumentation } from "@traceloop/instrumentation-langchain";
3838
import { ChromaDBInstrumentation } from "@traceloop/instrumentation-chromadb";
3939
import { QdrantInstrumentation } from "@traceloop/instrumentation-qdrant";
4040
import { TogetherInstrumentation } from "@traceloop/instrumentation-together";
41+
import { CerebrasInstrumentation } from "@traceloop/instrumentation-cerebras";
4142

4243
let _sdk: NodeSDK;
4344
let _spanProcessor: SimpleSpanProcessor | BatchSpanProcessor;
@@ -54,6 +55,7 @@ let pineconeInstrumentation: PineconeInstrumentation | undefined;
5455
let chromadbInstrumentation: ChromaDBInstrumentation | undefined;
5556
let qdrantInstrumentation: QdrantInstrumentation | undefined;
5657
let togetherInstrumentation: TogetherInstrumentation | undefined;
58+
let cerebrasInstrumentation: CerebrasInstrumentation | undefined;
5759

5860
const instrumentations: Instrumentation[] = [];
5961

@@ -111,6 +113,9 @@ export const initInstrumentations = () => {
111113

112114
togetherInstrumentation = new TogetherInstrumentation({ exceptionLogger });
113115
instrumentations.push(togetherInstrumentation);
116+
117+
cerebrasInstrumentation = new CerebrasInstrumentation({ exceptionLogger });
118+
instrumentations.push(cerebrasInstrumentation);
114119
};
115120

116121
export const manuallyInitInstrumentations = (
@@ -218,6 +223,12 @@ export const manuallyInitInstrumentations = (
218223
instrumentations.push(togetherInstrumentation);
219224
togetherInstrumentation.manuallyInstrument(instrumentModules.together);
220225
}
226+
227+
if (instrumentModules?.cerebras) {
228+
cerebrasInstrumentation = new CerebrasInstrumentation({ exceptionLogger });
229+
instrumentations.push(cerebrasInstrumentation);
230+
cerebrasInstrumentation.manuallyInstrument(instrumentModules.cerebras);
231+
}
221232
};
222233

223234
/**

0 commit comments

Comments
 (0)