@adminforth/completion-adapter-open-ai-chat-gpt 1.0.2 → 1.0.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Devforth.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -11,6 +11,9 @@ 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
13
  var _a;
14
+ // stop parameter is alredy not supported
15
+ // 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-4o-mini";
14
17
  const resp = yield fetch("https://api.openai.com/v1/chat/completions", {
15
18
  method: "POST",
16
19
  headers: {
@@ -18,7 +21,7 @@ export default class CompletionAdapterOpenAIChatGPT {
18
21
  Authorization: `Bearer ${this.options.openAiApiKey}`,
19
22
  },
20
23
  body: JSON.stringify({
21
- model: this.options.model || "gpt-4o-mini",
24
+ model,
22
25
  messages: [
23
26
  {
24
27
  role: "user",
@@ -26,8 +29,7 @@ export default class CompletionAdapterOpenAIChatGPT {
26
29
  },
27
30
  ],
28
31
  temperature: ((_a = this.options.expert) === null || _a === void 0 ? void 0 : _a.temperature) || 0.7,
29
- max_tokens: maxTokens,
30
- stop, //param
32
+ max_completion_tokens: maxTokens,
31
33
  }),
32
34
  });
33
35
  const data = yield resp.json();
package/index.ts CHANGED
@@ -21,6 +21,9 @@ export default class CompletionAdapterOpenAIChatGPT
21
21
  finishReason?: string;
22
22
  error?: string;
23
23
  }> => {
24
+ // stop parameter is alredy not supported
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-4o-mini";
24
27
  const resp = await fetch("https://api.openai.com/v1/chat/completions", {
25
28
  method: "POST",
26
29
  headers: {
@@ -28,7 +31,7 @@ export default class CompletionAdapterOpenAIChatGPT
28
31
  Authorization: `Bearer ${this.options.openAiApiKey}`,
29
32
  },
30
33
  body: JSON.stringify({
31
- model: this.options.model || "gpt-4o-mini",
34
+ model,
32
35
  messages: [
33
36
  {
34
37
  role: "user",
@@ -36,8 +39,7 @@ export default class CompletionAdapterOpenAIChatGPT
36
39
  },
37
40
  ],
38
41
  temperature: this.options.expert?.temperature || 0.7,
39
- max_tokens: maxTokens,
40
- stop, //param
42
+ max_completion_tokens: maxTokens,
41
43
  }),
42
44
  });
43
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": "1.0.2",
3
+ "version": "1.0.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",