@adminforth/completion-adapter-open-ai-chat-gpt 1.0.7 → 1.0.11

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 CHANGED
@@ -11,6 +11,8 @@ 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")
14
16
  const model = this.options.model || "gpt-4o-mini";
15
17
  const resp = yield fetch("https://api.openai.com/v1/chat/completions", {
16
18
  method: "POST",
@@ -18,18 +20,12 @@ export default class CompletionAdapterOpenAIChatGPT {
18
20
  "Content-Type": "application/json",
19
21
  Authorization: `Bearer ${this.options.openAiApiKey}`,
20
22
  },
21
- body: JSON.stringify({
22
- model,
23
- messages: [
23
+ body: JSON.stringify(Object.assign({ model, messages: [
24
24
  {
25
25
  role: "user",
26
26
  content, //param
27
27
  },
28
- ],
29
- temperature: ((_a = this.options.expert) === null || _a === void 0 ? void 0 : _a.temperature) || 0.7,
30
- max_completion_tokens: maxTokens,
31
- stop, //param
32
- }),
28
+ ], temperature: ((_a = this.options.expert) === null || _a === void 0 ? void 0 : _a.temperature) || 0.7, max_completion_tokens: maxTokens }, this.options.extraRequestBodyParameters)),
33
29
  });
34
30
  const data = yield resp.json();
35
31
  if (data.error) {
package/index.ts CHANGED
@@ -21,6 +21,8 @@ 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")
24
26
  const model = this.options.model || "gpt-4o-mini";
25
27
  const resp = await fetch("https://api.openai.com/v1/chat/completions", {
26
28
  method: "POST",
@@ -38,7 +40,7 @@ export default class CompletionAdapterOpenAIChatGPT
38
40
  ],
39
41
  temperature: this.options.expert?.temperature || 0.7,
40
42
  max_completion_tokens: maxTokens,
41
- stop, //param
43
+ ...this.options.extraRequestBodyParameters,
42
44
  }),
43
45
  });
44
46
  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.7",
3
+ "version": "1.0.11",
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
@@ -12,6 +12,12 @@ export interface AdapterOptions {
12
12
  */
13
13
  model?: string;
14
14
 
15
+ /**
16
+ * Additional request body parameters to include in the API request.
17
+ */
18
+ extraRequestBodyParameters?: Record<string, unknown>;
19
+
20
+
15
21
  /**
16
22
  * Expert settings
17
23
  */