@adminforth/completion-adapter-open-ai-chat-gpt 2.0.2 → 2.0.3

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
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  export default class CompletionAdapterOpenAIChatGPT {
11
11
  constructor(options) {
12
- this.complete = (content_1, ...args_1) => __awaiter(this, [content_1, ...args_1], void 0, function* (content, stop = ["."], maxTokens = 50) {
12
+ this.complete = (content_1, ...args_1) => __awaiter(this, [content_1, ...args_1], void 0, function* (content, stop = ["."], maxTokens = 50, outputSchema) {
13
13
  // stop parameter is alredy not supported
14
14
  // adapter users should explicitely ask model to stop at dot if needed (or "Complete only up to the end of sentence")
15
15
  const model = this.options.model || "gpt-5-nano";
@@ -24,7 +24,7 @@ export default class CompletionAdapterOpenAIChatGPT {
24
24
  role: "user",
25
25
  content, //param
26
26
  },
27
- ], max_completion_tokens: maxTokens }, this.options.extraRequestBodyParameters)),
27
+ ], max_completion_tokens: maxTokens, response_format: outputSchema ? Object.assign({ type: "json_schema" }, outputSchema) : undefined }, this.options.extraRequestBodyParameters)),
28
28
  });
29
29
  const data = yield resp.json();
30
30
  if (data.error) {
package/index.ts CHANGED
@@ -16,7 +16,7 @@ export default class CompletionAdapterOpenAIChatGPT
16
16
  }
17
17
  }
18
18
 
19
- complete = async (content: string, stop = ["."], maxTokens = 50): Promise<{
19
+ complete = async (content: string, stop = ["."], maxTokens = 50, outputSchema?: any): Promise<{
20
20
  content?: string;
21
21
  finishReason?: string;
22
22
  error?: string;
@@ -39,6 +39,10 @@ export default class CompletionAdapterOpenAIChatGPT
39
39
  },
40
40
  ],
41
41
  max_completion_tokens: maxTokens,
42
+ response_format: outputSchema ? {
43
+ type: "json_schema",
44
+ ...outputSchema,
45
+ } : undefined,
42
46
  ...this.options.extraRequestBodyParameters,
43
47
  }),
44
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/completion-adapter-open-ai-chat-gpt",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",