modelfusion 0.35.1 → 0.35.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/model-function/generate-structure/fixJson.cjs +8 -1
- package/model-function/generate-structure/fixJson.js +8 -1
- package/model-provider/openai/OpenAITextGenerationModel.cjs +4 -0
- package/model-provider/openai/OpenAITextGenerationModel.js +4 -0
- package/model-provider/openai/chat/OpenAIChatModel.cjs +4 -0
- package/model-provider/openai/chat/OpenAIChatModel.js +4 -0
- package/package.json +1 -1
@@ -2,7 +2,14 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.fixJson = void 0;
|
4
4
|
// Implemented as a scanner with additional fixing
|
5
|
-
// that performs a single linear time scan pass over the partial JSON
|
5
|
+
// that performs a single linear time scan pass over the partial JSON.
|
6
|
+
//
|
7
|
+
// The states should ideally match relevant states from the JSON spec:
|
8
|
+
// https://www.json.org/json-en.html
|
9
|
+
//
|
10
|
+
// Please note that invalid JSON is not considered/covered, because it
|
11
|
+
// is assumed that the resulting JSON will be processed by a standard
|
12
|
+
// JSON parser that will detect any invalid JSON.
|
6
13
|
function fixJson(input) {
|
7
14
|
const stack = ["ROOT"];
|
8
15
|
let lastValidIndex = -1;
|
@@ -1,5 +1,12 @@
|
|
1
1
|
// Implemented as a scanner with additional fixing
|
2
|
-
// that performs a single linear time scan pass over the partial JSON
|
2
|
+
// that performs a single linear time scan pass over the partial JSON.
|
3
|
+
//
|
4
|
+
// The states should ideally match relevant states from the JSON spec:
|
5
|
+
// https://www.json.org/json-en.html
|
6
|
+
//
|
7
|
+
// Please note that invalid JSON is not considered/covered, because it
|
8
|
+
// is assumed that the resulting JSON will be processed by a standard
|
9
|
+
// JSON parser that will detect any invalid JSON.
|
3
10
|
export function fixJson(input) {
|
4
11
|
const stack = ["ROOT"];
|
5
12
|
let lastValidIndex = -1;
|
@@ -277,6 +277,10 @@ const openAITextGenerationResponseSchema = zod_1.default.object({
|
|
277
277
|
}),
|
278
278
|
});
|
279
279
|
async function callOpenAITextGenerationAPI({ api = new OpenAIApiConfiguration_js_1.OpenAIApiConfiguration(), abortSignal, responseFormat, model, prompt, suffix, maxTokens, temperature, topP, n, logprobs, echo, stop, presencePenalty, frequencyPenalty, bestOf, logitBias, user, }) {
|
280
|
+
// empty arrays are not allowed for stop:
|
281
|
+
if (stop != null && Array.isArray(stop) && stop.length === 0) {
|
282
|
+
stop = undefined;
|
283
|
+
}
|
280
284
|
return (0, postToApi_js_1.postJsonToApi)({
|
281
285
|
url: api.assembleUrl("/completions"),
|
282
286
|
headers: api.headers,
|
@@ -267,6 +267,10 @@ const openAITextGenerationResponseSchema = z.object({
|
|
267
267
|
}),
|
268
268
|
});
|
269
269
|
async function callOpenAITextGenerationAPI({ api = new OpenAIApiConfiguration(), abortSignal, responseFormat, model, prompt, suffix, maxTokens, temperature, topP, n, logprobs, echo, stop, presencePenalty, frequencyPenalty, bestOf, logitBias, user, }) {
|
270
|
+
// empty arrays are not allowed for stop:
|
271
|
+
if (stop != null && Array.isArray(stop) && stop.length === 0) {
|
272
|
+
stop = undefined;
|
273
|
+
}
|
270
274
|
return postJsonToApi({
|
271
275
|
url: api.assembleUrl("/completions"),
|
272
276
|
headers: api.headers,
|
@@ -365,6 +365,10 @@ const openAIChatResponseSchema = zod_1.default.object({
|
|
365
365
|
}),
|
366
366
|
});
|
367
367
|
async function callOpenAIChatCompletionAPI({ api = new OpenAIApiConfiguration_js_1.OpenAIApiConfiguration(), abortSignal, responseFormat, model, messages, functions, functionCall, temperature, topP, n, stop, maxTokens, presencePenalty, frequencyPenalty, logitBias, user, }) {
|
368
|
+
// empty arrays are not allowed for stop:
|
369
|
+
if (stop != null && Array.isArray(stop) && stop.length === 0) {
|
370
|
+
stop = undefined;
|
371
|
+
}
|
368
372
|
return (0, postToApi_js_1.postJsonToApi)({
|
369
373
|
url: api.assembleUrl("/chat/completions"),
|
370
374
|
headers: api.headers,
|
@@ -355,6 +355,10 @@ const openAIChatResponseSchema = z.object({
|
|
355
355
|
}),
|
356
356
|
});
|
357
357
|
async function callOpenAIChatCompletionAPI({ api = new OpenAIApiConfiguration(), abortSignal, responseFormat, model, messages, functions, functionCall, temperature, topP, n, stop, maxTokens, presencePenalty, frequencyPenalty, logitBias, user, }) {
|
358
|
+
// empty arrays are not allowed for stop:
|
359
|
+
if (stop != null && Array.isArray(stop) && stop.length === 0) {
|
360
|
+
stop = undefined;
|
361
|
+
}
|
358
362
|
return postJsonToApi({
|
359
363
|
url: api.assembleUrl("/chat/completions"),
|
360
364
|
headers: api.headers,
|
package/package.json
CHANGED