notdiamond 0.3.4 → 0.3.8
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.cjs +14 -7
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +14 -7
- package/package.json +1 -1
- package/CHANGELOG.md +0 -11
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ function _interopNamespaceCompat(e) {
|
|
|
16
16
|
|
|
17
17
|
const dotenv__namespace = /*#__PURE__*/_interopNamespaceCompat(dotenv);
|
|
18
18
|
|
|
19
|
-
const version = "0.3.
|
|
19
|
+
const version = "0.3.7";
|
|
20
20
|
|
|
21
21
|
var __defProp = Object.defineProperty;
|
|
22
22
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -25,14 +25,18 @@ var __publicField = (obj, key, value) => {
|
|
|
25
25
|
return value;
|
|
26
26
|
};
|
|
27
27
|
dotenv__namespace.config();
|
|
28
|
-
const BASE_URL = "https://not-diamond-server.onrender.com";
|
|
29
|
-
const MODEL_SELECT_URL = `${BASE_URL}/v2/modelRouter/modelSelect`;
|
|
30
|
-
const FEEDBACK_URL = `${BASE_URL}/v2/report/metrics/feedback`;
|
|
31
28
|
const DEFAULT_TIMEOUT = 5;
|
|
29
|
+
const BASE_URL = "https://not-diamond-server.onrender.com";
|
|
32
30
|
class NotDiamond {
|
|
33
31
|
constructor(options = {}) {
|
|
34
32
|
__publicField(this, "apiKey");
|
|
33
|
+
__publicField(this, "apiUrl");
|
|
34
|
+
__publicField(this, "modelSelectUrl");
|
|
35
|
+
__publicField(this, "feedbackUrl");
|
|
35
36
|
this.apiKey = options.apiKey || process.env.NOTDIAMOND_API_KEY || "";
|
|
37
|
+
this.apiUrl = options.apiUrl || process.env.NOTDIAMOND_API_URL || BASE_URL;
|
|
38
|
+
this.modelSelectUrl = `${this.apiUrl}/v2/modelRouter/modelSelect`;
|
|
39
|
+
this.feedbackUrl = `${this.apiUrl}/v2/report/metrics/feedback`;
|
|
36
40
|
}
|
|
37
41
|
getAuthHeader() {
|
|
38
42
|
return `Bearer ${this.apiKey}`;
|
|
@@ -89,15 +93,18 @@ class NotDiamond {
|
|
|
89
93
|
...options.timeout ? { timeout: options.timeout } : {
|
|
90
94
|
timeout: DEFAULT_TIMEOUT
|
|
91
95
|
},
|
|
92
|
-
...options.default && { default: options.default }
|
|
96
|
+
...options.default && { default: options.default },
|
|
97
|
+
...options.previousSession && {
|
|
98
|
+
previous_session: options.previousSession
|
|
99
|
+
}
|
|
93
100
|
};
|
|
94
101
|
return this.postRequest(
|
|
95
|
-
|
|
102
|
+
this.modelSelectUrl,
|
|
96
103
|
requestBody
|
|
97
104
|
);
|
|
98
105
|
}
|
|
99
106
|
async feedback(options) {
|
|
100
|
-
return this.postRequest(
|
|
107
|
+
return this.postRequest(this.feedbackUrl, {
|
|
101
108
|
session_id: options.sessionId,
|
|
102
109
|
feedback: options.feedback,
|
|
103
110
|
provider: options.provider
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface NotDiamondOptions {
|
|
2
2
|
apiKey?: string;
|
|
3
|
+
apiUrl?: string;
|
|
3
4
|
}
|
|
4
5
|
interface Provider {
|
|
5
6
|
provider: string;
|
|
@@ -35,6 +36,7 @@ interface ModelSelectOptions {
|
|
|
35
36
|
hashContent?: boolean;
|
|
36
37
|
timeout?: number;
|
|
37
38
|
default?: Provider | number | string;
|
|
39
|
+
previousSession?: string;
|
|
38
40
|
}
|
|
39
41
|
interface ModelSelectSuccessResponse {
|
|
40
42
|
providers: Provider[];
|
|
@@ -54,6 +56,9 @@ interface FeedbackSuccessResponse {
|
|
|
54
56
|
}
|
|
55
57
|
declare class NotDiamond {
|
|
56
58
|
private apiKey;
|
|
59
|
+
private apiUrl;
|
|
60
|
+
private modelSelectUrl;
|
|
61
|
+
private feedbackUrl;
|
|
57
62
|
constructor(options?: NotDiamondOptions);
|
|
58
63
|
private getAuthHeader;
|
|
59
64
|
private postRequest;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface NotDiamondOptions {
|
|
2
2
|
apiKey?: string;
|
|
3
|
+
apiUrl?: string;
|
|
3
4
|
}
|
|
4
5
|
interface Provider {
|
|
5
6
|
provider: string;
|
|
@@ -35,6 +36,7 @@ interface ModelSelectOptions {
|
|
|
35
36
|
hashContent?: boolean;
|
|
36
37
|
timeout?: number;
|
|
37
38
|
default?: Provider | number | string;
|
|
39
|
+
previousSession?: string;
|
|
38
40
|
}
|
|
39
41
|
interface ModelSelectSuccessResponse {
|
|
40
42
|
providers: Provider[];
|
|
@@ -54,6 +56,9 @@ interface FeedbackSuccessResponse {
|
|
|
54
56
|
}
|
|
55
57
|
declare class NotDiamond {
|
|
56
58
|
private apiKey;
|
|
59
|
+
private apiUrl;
|
|
60
|
+
private modelSelectUrl;
|
|
61
|
+
private feedbackUrl;
|
|
57
62
|
constructor(options?: NotDiamondOptions);
|
|
58
63
|
private getAuthHeader;
|
|
59
64
|
private postRequest;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface NotDiamondOptions {
|
|
2
2
|
apiKey?: string;
|
|
3
|
+
apiUrl?: string;
|
|
3
4
|
}
|
|
4
5
|
interface Provider {
|
|
5
6
|
provider: string;
|
|
@@ -35,6 +36,7 @@ interface ModelSelectOptions {
|
|
|
35
36
|
hashContent?: boolean;
|
|
36
37
|
timeout?: number;
|
|
37
38
|
default?: Provider | number | string;
|
|
39
|
+
previousSession?: string;
|
|
38
40
|
}
|
|
39
41
|
interface ModelSelectSuccessResponse {
|
|
40
42
|
providers: Provider[];
|
|
@@ -54,6 +56,9 @@ interface FeedbackSuccessResponse {
|
|
|
54
56
|
}
|
|
55
57
|
declare class NotDiamond {
|
|
56
58
|
private apiKey;
|
|
59
|
+
private apiUrl;
|
|
60
|
+
private modelSelectUrl;
|
|
61
|
+
private feedbackUrl;
|
|
57
62
|
constructor(options?: NotDiamondOptions);
|
|
58
63
|
private getAuthHeader;
|
|
59
64
|
private postRequest;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as dotenv from 'dotenv';
|
|
2
2
|
|
|
3
|
-
const version = "0.3.
|
|
3
|
+
const version = "0.3.7";
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -9,14 +9,18 @@ var __publicField = (obj, key, value) => {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
dotenv.config();
|
|
12
|
-
const BASE_URL = "https://not-diamond-server.onrender.com";
|
|
13
|
-
const MODEL_SELECT_URL = `${BASE_URL}/v2/modelRouter/modelSelect`;
|
|
14
|
-
const FEEDBACK_URL = `${BASE_URL}/v2/report/metrics/feedback`;
|
|
15
12
|
const DEFAULT_TIMEOUT = 5;
|
|
13
|
+
const BASE_URL = "https://not-diamond-server.onrender.com";
|
|
16
14
|
class NotDiamond {
|
|
17
15
|
constructor(options = {}) {
|
|
18
16
|
__publicField(this, "apiKey");
|
|
17
|
+
__publicField(this, "apiUrl");
|
|
18
|
+
__publicField(this, "modelSelectUrl");
|
|
19
|
+
__publicField(this, "feedbackUrl");
|
|
19
20
|
this.apiKey = options.apiKey || process.env.NOTDIAMOND_API_KEY || "";
|
|
21
|
+
this.apiUrl = options.apiUrl || process.env.NOTDIAMOND_API_URL || BASE_URL;
|
|
22
|
+
this.modelSelectUrl = `${this.apiUrl}/v2/modelRouter/modelSelect`;
|
|
23
|
+
this.feedbackUrl = `${this.apiUrl}/v2/report/metrics/feedback`;
|
|
20
24
|
}
|
|
21
25
|
getAuthHeader() {
|
|
22
26
|
return `Bearer ${this.apiKey}`;
|
|
@@ -73,15 +77,18 @@ class NotDiamond {
|
|
|
73
77
|
...options.timeout ? { timeout: options.timeout } : {
|
|
74
78
|
timeout: DEFAULT_TIMEOUT
|
|
75
79
|
},
|
|
76
|
-
...options.default && { default: options.default }
|
|
80
|
+
...options.default && { default: options.default },
|
|
81
|
+
...options.previousSession && {
|
|
82
|
+
previous_session: options.previousSession
|
|
83
|
+
}
|
|
77
84
|
};
|
|
78
85
|
return this.postRequest(
|
|
79
|
-
|
|
86
|
+
this.modelSelectUrl,
|
|
80
87
|
requestBody
|
|
81
88
|
);
|
|
82
89
|
}
|
|
83
90
|
async feedback(options) {
|
|
84
|
-
return this.postRequest(
|
|
91
|
+
return this.postRequest(this.feedbackUrl, {
|
|
85
92
|
session_id: options.sessionId,
|
|
86
93
|
feedback: options.feedback,
|
|
87
94
|
provider: options.provider
|
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
## [0.0.2](https://github.com/Not-Diamond/notdiamond-node/pull/4) (2024-05-22)
|
|
2
|
-
|
|
3
|
-
### Bug Fixes
|
|
4
|
-
|
|
5
|
-
- Cleaned up readme [4c33bd8be65850ef4c5ca34aa9d18c60ee44ead5](https://github.com/Not-Diamond/notdiamond-node/pull/4/commits/4c33bd8be65850ef4c5ca34aa9d18c60ee44ead5)
|
|
6
|
-
|
|
7
|
-
## [0.0.1](https://github.com/Not-Diamond/notdiamond-node/tree/32bccf352544414e1486c170b90cf00f75041190) (2024-05-22)
|
|
8
|
-
|
|
9
|
-
### Initial release
|
|
10
|
-
|
|
11
|
-
- Code setup
|