@sprucelabs/sprucebot-llm 2.5.0 → 2.5.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.
|
@@ -14,13 +14,18 @@ class OpenAiAdapter {
|
|
|
14
14
|
this.api = new OpenAiAdapter.OpenAIApi(config);
|
|
15
15
|
}
|
|
16
16
|
async sendMessage(bot, options) {
|
|
17
|
-
var _a, _b, _c;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
18
|
const generator = PromptGenerator_1.default.Generator(bot, {
|
|
19
19
|
promptTemplate: options === null || options === void 0 ? void 0 : options.promptTemplate,
|
|
20
20
|
});
|
|
21
21
|
const prompt = await generator.generate();
|
|
22
|
-
const response = await this.api.createCompletion(
|
|
23
|
-
|
|
22
|
+
const response = await this.api.createCompletion({
|
|
23
|
+
prompt,
|
|
24
|
+
model: (_a = options === null || options === void 0 ? void 0 : options.model) !== null && _a !== void 0 ? _a : 'text-davinci-003',
|
|
25
|
+
max_tokens: 250,
|
|
26
|
+
stop: ['__Me__:'],
|
|
27
|
+
});
|
|
28
|
+
return ((_d = (_c = (_b = response.data.choices[0]) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : exports.MESSAGE_RESPONSE_ERROR_MESSAGE);
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
OpenAiAdapter.Configuration = openai_1.Configuration;
|
|
@@ -17,14 +17,19 @@ class OpenAiAdapter {
|
|
|
17
17
|
this.api = new OpenAiAdapter.OpenAIApi(config);
|
|
18
18
|
}
|
|
19
19
|
sendMessage(bot, options) {
|
|
20
|
-
var _a, _b, _c;
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const generator = PromptGenerator.Generator(bot, {
|
|
23
23
|
promptTemplate: options === null || options === void 0 ? void 0 : options.promptTemplate,
|
|
24
24
|
});
|
|
25
25
|
const prompt = yield generator.generate();
|
|
26
|
-
const response = yield this.api.createCompletion(
|
|
27
|
-
|
|
26
|
+
const response = yield this.api.createCompletion({
|
|
27
|
+
prompt,
|
|
28
|
+
model: (_a = options === null || options === void 0 ? void 0 : options.model) !== null && _a !== void 0 ? _a : 'text-davinci-003',
|
|
29
|
+
max_tokens: 250,
|
|
30
|
+
stop: ['__Me__:'],
|
|
31
|
+
});
|
|
32
|
+
return ((_d = (_c = (_b = response.data.choices[0]) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : MESSAGE_RESPONSE_ERROR_MESSAGE);
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
35
|
}
|