openlayer 0.1.14 → 0.1.16
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 +4 -0
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ Install with npm
|
|
|
26
26
|
npm i openlayer
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
[Example usage available in our docs](https://docs.openlayer.com/quickstarts/llm-quickstart)
|
|
32
|
+
|
|
29
33
|
## Documentation
|
|
30
34
|
|
|
31
35
|
The official documentation for this library can be found [here](https://docs.openlayer.com).
|
package/dist/index.js
CHANGED
|
@@ -258,7 +258,8 @@ class OpenAIMonitor {
|
|
|
258
258
|
.filter(({ role }) => role === 'user')
|
|
259
259
|
.map(({ content }) => content);
|
|
260
260
|
const inputVariablesMap = inputVariableNames.reduce((acc, name, i) => (Object.assign(Object.assign({}, acc), { [name]: inputVariables[i] })), {});
|
|
261
|
-
const config = Object.assign(Object.assign({}, this.openlayerClient.defaultConfig), { inputVariableNames
|
|
261
|
+
const config = Object.assign(Object.assign({}, this.openlayerClient.defaultConfig), { inputVariableNames,
|
|
262
|
+
prompt });
|
|
262
263
|
if (body.stream) {
|
|
263
264
|
const streamedResponse = response;
|
|
264
265
|
try {
|
|
@@ -279,7 +280,7 @@ class OpenAIMonitor {
|
|
|
279
280
|
}
|
|
280
281
|
const endTime = Date.now();
|
|
281
282
|
const latency = endTime - startTime;
|
|
282
|
-
this.openlayerClient.streamData(Object.assign({ latency, output: outputData,
|
|
283
|
+
this.openlayerClient.streamData(Object.assign({ latency, output: outputData, timestamp: startTime }, inputVariablesMap), config, inferencePipeline.id);
|
|
283
284
|
}
|
|
284
285
|
else {
|
|
285
286
|
const nonStreamedResponse = response;
|
|
@@ -291,8 +292,7 @@ class OpenAIMonitor {
|
|
|
291
292
|
throw new Error('No output received from OpenAI.');
|
|
292
293
|
}
|
|
293
294
|
this.openlayerClient.streamData(Object.assign({ latency,
|
|
294
|
-
output,
|
|
295
|
-
prompt, timestamp: startTime, tokens: (_e = (_d = nonStreamedResponse.usage) === null || _d === void 0 ? void 0 : _d.total_tokens) !== null && _e !== void 0 ? _e : 0 }, inputVariablesMap), config, inferencePipeline.id);
|
|
295
|
+
output, timestamp: startTime, tokens: (_e = (_d = nonStreamedResponse.usage) === null || _d === void 0 ? void 0 : _d.total_tokens) !== null && _e !== void 0 ? _e : 0 }, inputVariablesMap), config, inferencePipeline.id);
|
|
296
296
|
}
|
|
297
297
|
return response;
|
|
298
298
|
});
|