polyfire-js
Advanced tools
Comparing version 0.2.38 to 0.2.39
@@ -140,21 +140,22 @@ "use strict"; | ||
var generateCompletion = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var systemPrompt, generation, _a, error_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var systemPrompt, generation, completion_1, limitedCompletion, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (status !== "authenticated" || !prompt || completionUsed) | ||
return [2 /*return*/]; | ||
_b.label = 1; | ||
_a.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
systemPrompt = "Your role is to predict what the user will type next. \n Don't answer the user because there is only one user who speaks. \n Only answer with the prediction until the end of the sentence. \n Don't explain anything about the prediction. \n Don't repeat what the user said. \n Complete from where the user stopped typing. \n Just answer only one or two words (never more words)."; | ||
_a.trys.push([1, 3, , 4]); | ||
systemPrompt = "Your role is to predict what the user will type next. \n Don't answer the user because there is only one user who speaks. \n Only answer with the prediction until the end of the sentence. \n Don't explain anything about the prediction. \n Don't repeat what the user said. \n Complete from where the user stopped typing."; | ||
generation = generate(prompt, { systemPrompt: systemPrompt, autoComplete: true }); | ||
generationRef.current = generation; | ||
_a = setCompletion; | ||
return [4 /*yield*/, generation]; | ||
case 2: | ||
_a.apply(void 0, [_b.sent()]); | ||
completion_1 = _a.sent(); | ||
limitedCompletion = completion_1.split(" ").slice(0, 5).join(" "); | ||
setCompletion(limitedCompletion); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_1 = _b.sent(); | ||
error_1 = _a.sent(); | ||
console.error("Error generating completion:", error_1); | ||
@@ -161,0 +162,0 @@ return [3 /*break*/, 4]; |
@@ -92,3 +92,4 @@ "use strict"; | ||
generation.then(function (text) { | ||
setCompletion({ text: text, position: caretPosition }); | ||
var limitedCompletion = text.split(" ").slice(0, 15).join(" "); | ||
setCompletion({ text: limitedCompletion, position: caretPosition }); | ||
}); | ||
@@ -95,0 +96,0 @@ } |
{ | ||
"name": "polyfire-js", | ||
"version": "0.2.38", | ||
"version": "0.2.39", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
270522
5504