opik 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -6
- package/dist/Client-BFXzOx36.d.cts +5603 -0
- package/dist/Client-BFXzOx36.d.ts +5603 -0
- package/dist/Node18UniversalStreamWrapper-GZXI7BSF.js +1 -0
- package/dist/NodePre18StreamWrapper-TZYQXHQT.js +1 -0
- package/dist/UndiciStreamWrapper-4QYH36IP.js +1 -0
- package/dist/chunk-37E5PSYD.js +4 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/index.cjs +4 -12476
- package/dist/index.d.cts +30 -4629
- package/dist/index.d.ts +30 -4629
- package/dist/index.js +1 -11910
- package/dist/vercel/index.cjs +4 -0
- package/dist/vercel/index.d.cts +42 -0
- package/dist/vercel/index.d.ts +42 -0
- package/dist/vercel/index.js +1 -0
- package/package.json +26 -5
- package/dist/Node18UniversalStreamWrapper-5PLK6H2I.js +0 -216
- package/dist/Node18UniversalStreamWrapper-RYU62PI4.js +0 -220
- package/dist/NodePre18StreamWrapper-PJE27LW2.js +0 -88
- package/dist/NodePre18StreamWrapper-U7T7ZEM6.js +0 -90
- package/dist/UndiciStreamWrapper-E5ZREEPW.js +0 -208
- package/dist/UndiciStreamWrapper-M2WUKUR4.js +0 -204
- package/dist/chunk-MLKGABMK.js +0 -9
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<h1 align="center" style="border-bottom: none">
|
|
2
2
|
<div>
|
|
3
3
|
<a href="https://www.comet.com/site/products/opik/?from=llm&utm_source=opik&utm_medium=github&utm_content=header_img&utm_campaign=opik"><picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="/apps/opik-documentation/documentation/static/img/logo-dark-mode.svg">
|
|
5
|
-
<source media="(prefers-color-scheme: light)" srcset="https://
|
|
6
|
-
<img alt="Comet Opik logo" src="https://
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/logo-dark-mode.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/opik-logo.svg">
|
|
6
|
+
<img alt="Comet Opik logo" src="https://raw.githubusercontent.com/comet-ml/opik/refs/heads/main/apps/opik-documentation/documentation/static/img/opik-logo.svg" width="200" />
|
|
7
7
|
</picture></a>
|
|
8
8
|
<br>
|
|
9
9
|
Opik
|
|
@@ -19,23 +19,50 @@ You can install the `opik` package using your favorite package manager.
|
|
|
19
19
|
npm install opik
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Opik Configuration
|
|
23
|
+
|
|
24
|
+
You can configure the Opik client using environment variables.
|
|
25
|
+
|
|
26
|
+
`.env` file:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
OPIK_API_KEY="your-api-key"
|
|
30
|
+
OPIK_URL_OVERRIDE="https://www.comet.com/opik/api"
|
|
31
|
+
OPIK_PROJECT_NAME="your-project-name"
|
|
32
|
+
OPIK_WORKSPACE_NAME="your-workspace-name"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or you can pass the configuration to the Opik client constructor.
|
|
23
36
|
|
|
24
37
|
```typescript
|
|
25
38
|
import { Opik } from "opik";
|
|
26
39
|
|
|
27
|
-
// Create a new Opik client with your configuration
|
|
28
40
|
const client = new Opik({
|
|
29
41
|
apiKey: "<your-api-key>",
|
|
30
|
-
|
|
42
|
+
apiUrl: "https://www.comet.com/opik/api",
|
|
31
43
|
projectName: "<your-project-name>",
|
|
32
44
|
workspaceName: "<your-workspace-name>",
|
|
33
45
|
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Opik } from "opik";
|
|
52
|
+
|
|
53
|
+
// Create a new Opik client with your configuration
|
|
54
|
+
const client = new Opik();
|
|
34
55
|
|
|
35
56
|
// Log 10 traces
|
|
36
57
|
for (let i = 0; i < 10; i++) {
|
|
37
58
|
const someTrace = client.trace({
|
|
38
59
|
name: `Trace ${i}`,
|
|
60
|
+
input: {
|
|
61
|
+
prompt: `Hello, world! ${i}`,
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
response: `Hello, world! ${i}`,
|
|
65
|
+
},
|
|
39
66
|
});
|
|
40
67
|
|
|
41
68
|
// For each trace, log 10 spans
|
|
@@ -43,8 +70,17 @@ for (let i = 0; i < 10; i++) {
|
|
|
43
70
|
const someSpan = someTrace.span({
|
|
44
71
|
name: `Span ${i}-${j}`,
|
|
45
72
|
type: "llm",
|
|
73
|
+
input: {
|
|
74
|
+
prompt: `Hello, world! ${i}:${j}`,
|
|
75
|
+
},
|
|
76
|
+
output: {
|
|
77
|
+
response: `Hello, world! ${i}:${j}`,
|
|
78
|
+
},
|
|
46
79
|
});
|
|
47
80
|
|
|
81
|
+
// Some LLM work
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
83
|
+
|
|
48
84
|
// Mark the span as ended
|
|
49
85
|
someSpan.end();
|
|
50
86
|
}
|
|
@@ -57,6 +93,56 @@ for (let i = 0; i < 10; i++) {
|
|
|
57
93
|
await client.flush();
|
|
58
94
|
```
|
|
59
95
|
|
|
96
|
+
## Vercel AI SDK Integration
|
|
97
|
+
|
|
98
|
+
Opik provides seamless integration with the Vercel AI SDK through OpenTelemetry instrumentation.
|
|
99
|
+
|
|
100
|
+
### Installation
|
|
101
|
+
|
|
102
|
+
Install the required dependencies:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install opik ai @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Usage
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { openai } from "@ai-sdk/openai";
|
|
112
|
+
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
113
|
+
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
114
|
+
import { generateText } from "ai";
|
|
115
|
+
import { OpikExporter } from "opik/vercel";
|
|
116
|
+
|
|
117
|
+
const sdk = new NodeSDK({
|
|
118
|
+
traceExporter: new OpikExporter(),
|
|
119
|
+
instrumentations: [getNodeAutoInstrumentations()],
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
sdk.start();
|
|
123
|
+
|
|
124
|
+
const { text } = await generateText({
|
|
125
|
+
model: openai("gpt-4o-mini"),
|
|
126
|
+
prompt: "What is love? Describe it in 10 words or less.",
|
|
127
|
+
experimental_telemetry: OpikExporter.getSettings({
|
|
128
|
+
name: "ai-sdk-integration",
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await sdk.shutdown();
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This integration automatically captures:
|
|
136
|
+
|
|
137
|
+
- Input prompts and messages
|
|
138
|
+
- Model responses
|
|
139
|
+
- Token usage statistics
|
|
140
|
+
- Tool calls and their results
|
|
141
|
+
- Timing information
|
|
142
|
+
- Error states
|
|
143
|
+
|
|
144
|
+
All this telemetry data is automatically sent to your Opik project for analysis and monitoring.
|
|
145
|
+
|
|
60
146
|
## Contributing
|
|
61
147
|
|
|
62
148
|
Contributions are welcome! If you have any suggestions or improvements, please feel free to open an [issue](https://github.com/comet-ml/opik/issues) or submit a [pull request](https://github.com/comet-ml/opik/pulls).
|