@adminforth/completion-adapter-open-ai-chat-gpt 1.0.9 → 2.0.2
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 +3 -9
- package/index.ts +2 -2
- package/package.json +5 -2
- package/types.ts +2 -7
package/dist/index.js
CHANGED
|
@@ -10,27 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
export default class CompletionAdapterOpenAIChatGPT {
|
|
11
11
|
constructor(options) {
|
|
12
12
|
this.complete = (content_1, ...args_1) => __awaiter(this, [content_1, ...args_1], void 0, function* (content, stop = ["."], maxTokens = 50) {
|
|
13
|
-
var _a;
|
|
14
13
|
// stop parameter is alredy not supported
|
|
15
14
|
// adapter users should explicitely ask model to stop at dot if needed (or "Complete only up to the end of sentence")
|
|
16
|
-
const model = this.options.model || "gpt-
|
|
15
|
+
const model = this.options.model || "gpt-5-nano";
|
|
17
16
|
const resp = yield fetch("https://api.openai.com/v1/chat/completions", {
|
|
18
17
|
method: "POST",
|
|
19
18
|
headers: {
|
|
20
19
|
"Content-Type": "application/json",
|
|
21
20
|
Authorization: `Bearer ${this.options.openAiApiKey}`,
|
|
22
21
|
},
|
|
23
|
-
body: JSON.stringify({
|
|
24
|
-
model,
|
|
25
|
-
messages: [
|
|
22
|
+
body: JSON.stringify(Object.assign({ model, messages: [
|
|
26
23
|
{
|
|
27
24
|
role: "user",
|
|
28
25
|
content, //param
|
|
29
26
|
},
|
|
30
|
-
],
|
|
31
|
-
temperature: ((_a = this.options.expert) === null || _a === void 0 ? void 0 : _a.temperature) || 0.7,
|
|
32
|
-
max_completion_tokens: maxTokens,
|
|
33
|
-
}),
|
|
27
|
+
], max_completion_tokens: maxTokens }, this.options.extraRequestBodyParameters)),
|
|
34
28
|
});
|
|
35
29
|
const data = yield resp.json();
|
|
36
30
|
if (data.error) {
|
package/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ export default class CompletionAdapterOpenAIChatGPT
|
|
|
23
23
|
}> => {
|
|
24
24
|
// stop parameter is alredy not supported
|
|
25
25
|
// adapter users should explicitely ask model to stop at dot if needed (or "Complete only up to the end of sentence")
|
|
26
|
-
const model = this.options.model || "gpt-
|
|
26
|
+
const model = this.options.model || "gpt-5-nano";
|
|
27
27
|
const resp = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
28
28
|
method: "POST",
|
|
29
29
|
headers: {
|
|
@@ -38,8 +38,8 @@ export default class CompletionAdapterOpenAIChatGPT
|
|
|
38
38
|
content, //param
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
|
-
temperature: this.options.expert?.temperature || 0.7,
|
|
42
41
|
max_completion_tokens: maxTokens,
|
|
42
|
+
...this.options.extraRequestBodyParameters,
|
|
43
43
|
}),
|
|
44
44
|
});
|
|
45
45
|
const data = await resp.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/completion-adapter-open-ai-chat-gpt",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -12,5 +12,8 @@
|
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
|
-
"description": ""
|
|
15
|
+
"description": "",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^5.9.3"
|
|
18
|
+
}
|
|
16
19
|
}
|
package/types.ts
CHANGED
|
@@ -13,12 +13,7 @@ export interface AdapterOptions {
|
|
|
13
13
|
model?: string;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Additional request body parameters to include in the API request.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Temperature (0-1). Lower is more deterministic, higher is more unpredicted creative. Default is 0.7.
|
|
21
|
-
*/
|
|
22
|
-
temperature?: number;
|
|
23
|
-
};
|
|
18
|
+
extraRequestBodyParameters?: Record<string, unknown>;
|
|
24
19
|
}
|