openlayer 0.1.23 → 0.1.25
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/dist/index.js +9 -2
- package/examples/openai_monitor.mjs +6 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61,6 +61,10 @@ const OpenAIPricing = {
|
|
|
61
61
|
input: 0.03,
|
|
62
62
|
output: 0.06,
|
|
63
63
|
},
|
|
64
|
+
'gpt-4-0613': {
|
|
65
|
+
input: 0.03,
|
|
66
|
+
output: 0.06,
|
|
67
|
+
},
|
|
64
68
|
'gpt-4-1106-preview': {
|
|
65
69
|
input: 0.01,
|
|
66
70
|
output: 0.03,
|
|
@@ -77,6 +81,10 @@ const OpenAIPricing = {
|
|
|
77
81
|
input: 0.06,
|
|
78
82
|
output: 0.12,
|
|
79
83
|
},
|
|
84
|
+
'gpt-4-32k-0613': {
|
|
85
|
+
input: 0.03,
|
|
86
|
+
output: 0.06,
|
|
87
|
+
},
|
|
80
88
|
};
|
|
81
89
|
class OpenlayerClient {
|
|
82
90
|
/**
|
|
@@ -368,8 +376,7 @@ class OpenAIMonitor {
|
|
|
368
376
|
throw new Error('No output received from OpenAI.');
|
|
369
377
|
}
|
|
370
378
|
this.openlayerClient.streamData(Object.assign(Object.assign({ cost,
|
|
371
|
-
latency,
|
|
372
|
-
output, timestamp: startTime, tokens }, inputVariablesMap), additionalLogs), config, this.inferencePipeline.id);
|
|
379
|
+
latency, model: nonStreamedResponse.model, output, timestamp: startTime, tokens }, inputVariablesMap), additionalLogs), config, this.inferencePipeline.id);
|
|
373
380
|
}
|
|
374
381
|
return response;
|
|
375
382
|
});
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
import { OpenAIMonitor } from 'openlayer';
|
|
6
6
|
|
|
7
7
|
const monitor = new OpenAIMonitor({
|
|
8
|
-
openAiApiKey: '
|
|
9
|
-
openlayerApiKey: '
|
|
8
|
+
openAiApiKey: 'YOUR_OPENAI_API_KEY',
|
|
9
|
+
openlayerApiKey: 'YOUR_OPENLAYER_API_KEY',
|
|
10
10
|
openlayerInferencePipelineName: 'production',
|
|
11
|
-
openlayerProjectName: '
|
|
12
|
-
openlayerServerUrl: 'http://localhost:8080/v1',
|
|
11
|
+
openlayerProjectName: 'YOUR_OPENLAYER_PROJECT_NAME',
|
|
13
12
|
});
|
|
14
13
|
|
|
15
14
|
await monitor.startMonitoring();
|
|
@@ -37,7 +36,7 @@ for (let i = 0; i < inputs.length; i++) {
|
|
|
37
36
|
messages: [
|
|
38
37
|
{
|
|
39
38
|
content: systemMessage,
|
|
40
|
-
role: '
|
|
39
|
+
role: 'system',
|
|
41
40
|
},
|
|
42
41
|
{
|
|
43
42
|
content: userMessage,
|
|
@@ -53,3 +52,5 @@ for (let i = 0; i < inputs.length; i++) {
|
|
|
53
52
|
}
|
|
54
53
|
);
|
|
55
54
|
}
|
|
55
|
+
|
|
56
|
+
monitor.stopMonitoring();
|