openlayer 0.1.13 → 0.1.15
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.d.ts +6 -2
- package/dist/index.js +9 -6
- 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.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export interface StreamingData {
|
|
|
15
15
|
* The output string generated by the chat completion.
|
|
16
16
|
*/
|
|
17
17
|
output: string;
|
|
18
|
+
/**
|
|
19
|
+
* The full prompt history for the chat completion.
|
|
20
|
+
*/
|
|
21
|
+
prompt?: ChatCompletionMessageParam[];
|
|
18
22
|
/**
|
|
19
23
|
* A timestamp representing when the chat completion occurred. Optional.
|
|
20
24
|
*/
|
|
@@ -53,9 +57,9 @@ interface StreamingDataConfig {
|
|
|
53
57
|
*/
|
|
54
58
|
outputColumnName: string | null;
|
|
55
59
|
/**
|
|
56
|
-
* The
|
|
60
|
+
* The name of the column that stores the prompt template. Can be null.
|
|
57
61
|
*/
|
|
58
|
-
|
|
62
|
+
promptColumnName: string | null;
|
|
59
63
|
/**
|
|
60
64
|
* The name of the column that stores timestamp data. Can be null.
|
|
61
65
|
*/
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ class OpenlayerClient {
|
|
|
33
33
|
latencyColumnName: 'latency',
|
|
34
34
|
numOfTokenColumnName: 'tokens',
|
|
35
35
|
outputColumnName: 'output',
|
|
36
|
+
promptColumnName: 'prompt',
|
|
36
37
|
timestampColumnName: 'timestamp',
|
|
37
38
|
};
|
|
38
39
|
this.openlayerServerUrl = 'https://api.openlayer.com/v1';
|
|
@@ -124,7 +125,7 @@ class OpenlayerClient {
|
|
|
124
125
|
catch (_c) {
|
|
125
126
|
const projectsEndpoint = '/projects';
|
|
126
127
|
const projectsQuery = this.resolvedQuery(projectsEndpoint);
|
|
127
|
-
const
|
|
128
|
+
const response = yield fetch(projectsQuery, {
|
|
128
129
|
body: JSON.stringify({
|
|
129
130
|
description,
|
|
130
131
|
name,
|
|
@@ -136,9 +137,10 @@ class OpenlayerClient {
|
|
|
136
137
|
},
|
|
137
138
|
method: 'POST',
|
|
138
139
|
});
|
|
139
|
-
const
|
|
140
|
+
const data = yield response.json();
|
|
141
|
+
const { items: projects, error } = data;
|
|
140
142
|
if (!Array.isArray(projects)) {
|
|
141
|
-
throw new Error('Invalid response from Openlayer');
|
|
143
|
+
throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
|
|
142
144
|
}
|
|
143
145
|
const project = projects.find((p) => p.name === name);
|
|
144
146
|
if (!(project === null || project === void 0 ? void 0 : project.id)) {
|
|
@@ -190,16 +192,17 @@ class OpenlayerClient {
|
|
|
190
192
|
version: this.version,
|
|
191
193
|
};
|
|
192
194
|
const projectsQuery = this.resolvedQuery(projectsEndpoint, projectsQueryParameters);
|
|
193
|
-
const
|
|
195
|
+
const response = yield fetch(projectsQuery, {
|
|
194
196
|
headers: {
|
|
195
197
|
Authorization: `Bearer ${this.openlayerApiKey}`,
|
|
196
198
|
'Content-Type': 'application/json',
|
|
197
199
|
},
|
|
198
200
|
method: 'GET',
|
|
199
201
|
});
|
|
200
|
-
const
|
|
202
|
+
const data = yield response.json();
|
|
203
|
+
const { items: projects, error } = data;
|
|
201
204
|
if (!Array.isArray(projects)) {
|
|
202
|
-
throw new Error('Invalid response from Openlayer');
|
|
205
|
+
throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
|
|
203
206
|
}
|
|
204
207
|
const project = projects.find((p) => p.name === name);
|
|
205
208
|
if (!(project === null || project === void 0 ? void 0 : project.id)) {
|