@sprucelabs/sprucebot-llm 0.0.3 → 0.1.0
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/build/bots/adapters/OpenAi.d.ts +1 -1
- package/build/bots/adapters/OpenAi.js +8 -8
- package/build/chat.js +2 -2
- package/build/esm/bots/adapters/OpenAi.d.ts +1 -1
- package/build/esm/bots/adapters/OpenAi.js +6 -6
- package/build/esm/chat.js +3 -3
- package/build/esm/examples/buildCallbackSkill.d.ts +1 -1
- package/build/esm/examples/buildCallbackSkill.js +3 -0
- package/build/esm/examples/buildFileTransformerSkill.d.ts +1 -1
- package/build/esm/examples/buildJokeSkill.d.ts +1 -1
- package/build/esm/examples/buildProfileSkill.d.ts +1 -1
- package/build/esm/index.d.ts +3 -0
- package/build/esm/index.js +3 -2
- package/build/examples/buildCallbackSkill.d.ts +1 -1
- package/build/examples/buildCallbackSkill.js +3 -0
- package/build/examples/buildFileTransformerSkill.d.ts +1 -1
- package/build/examples/buildJokeSkill.d.ts +1 -1
- package/build/examples/buildProfileSkill.d.ts +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +24 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Configuration, OpenAIApi } from 'openai';
|
|
2
2
|
import { LlmAdapter, SprucebotLlmBot } from '../../llm.types';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class OpenAiAdapter implements LlmAdapter {
|
|
4
4
|
static Configuration: typeof Configuration;
|
|
5
5
|
static OpenAIApi: typeof OpenAIApi;
|
|
6
6
|
private api;
|
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MESSAGE_RESPONSE_ERROR_MESSAGE = exports.
|
|
6
|
+
exports.MESSAGE_RESPONSE_ERROR_MESSAGE = exports.OpenAiAdapter = void 0;
|
|
7
7
|
const schema_1 = require("@sprucelabs/schema");
|
|
8
8
|
const openai_1 = require("openai");
|
|
9
9
|
const PromptGenerator_1 = __importDefault(require("../PromptGenerator"));
|
|
10
|
-
class
|
|
10
|
+
class OpenAiAdapter {
|
|
11
11
|
constructor(apiKey) {
|
|
12
12
|
(0, schema_1.assertOptions)({ apiKey }, ['apiKey']);
|
|
13
|
-
const config = new
|
|
14
|
-
this.api = new
|
|
13
|
+
const config = new OpenAiAdapter.Configuration({ apiKey });
|
|
14
|
+
this.api = new OpenAiAdapter.OpenAIApi(config);
|
|
15
15
|
}
|
|
16
16
|
async sendMessage(bot) {
|
|
17
17
|
var _a, _b, _c;
|
|
@@ -20,13 +20,13 @@ class OpenAi {
|
|
|
20
20
|
const response = await this.api.createCompletion({
|
|
21
21
|
prompt,
|
|
22
22
|
model: 'text-davinci-003',
|
|
23
|
-
max_tokens:
|
|
23
|
+
max_tokens: 250,
|
|
24
24
|
stop: ['__Me__:'],
|
|
25
25
|
});
|
|
26
26
|
return ((_c = (_b = (_a = response.data.choices[0]) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : exports.MESSAGE_RESPONSE_ERROR_MESSAGE);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
exports.OpenAiAdapter = OpenAiAdapter;
|
|
30
|
+
OpenAiAdapter.Configuration = openai_1.Configuration;
|
|
31
|
+
OpenAiAdapter.OpenAIApi = openai_1.OpenAIApi;
|
|
32
32
|
exports.MESSAGE_RESPONSE_ERROR_MESSAGE = "Oh no! Something went wrong and I can't talk right now!";
|
package/build/chat.js
CHANGED
|
@@ -39,7 +39,7 @@ dotenv_1.default.config();
|
|
|
39
39
|
const rl = readline.createInterface({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
40
40
|
(async () => {
|
|
41
41
|
console.clear();
|
|
42
|
-
const adapter = new OpenAi_1.
|
|
42
|
+
const adapter = new OpenAi_1.OpenAiAdapter(process.env.OPEN_AI_API_KEY);
|
|
43
43
|
const bots = SprucebotLlmFactory_1.default.Factory();
|
|
44
44
|
const skills = {
|
|
45
45
|
jokes: (0, buildJokeSkill_1.default)(bots),
|
|
@@ -49,7 +49,7 @@ const rl = readline.createInterface({ input: node_process_1.stdin, output: node_
|
|
|
49
49
|
};
|
|
50
50
|
const bot = bots.Bot({
|
|
51
51
|
adapter,
|
|
52
|
-
skill: skills.
|
|
52
|
+
skill: skills.profile,
|
|
53
53
|
youAre: "a bot named Sprucebot that is in test mode. At the start of every conversation, you introduce yourself and announce that you are in test mode so I don't get confused! You are both hip and adorable. You say things like, 'Jeepers' and 'Golly' or even 'Jeezey peezy'!",
|
|
54
54
|
});
|
|
55
55
|
do {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Configuration, OpenAIApi } from 'openai';
|
|
2
2
|
import { LlmAdapter, SprucebotLlmBot } from '../../llm.types';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class OpenAiAdapter implements LlmAdapter {
|
|
4
4
|
static Configuration: typeof Configuration;
|
|
5
5
|
static OpenAIApi: typeof OpenAIApi;
|
|
6
6
|
private api;
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { assertOptions } from '@sprucelabs/schema';
|
|
11
11
|
import { Configuration, OpenAIApi } from 'openai';
|
|
12
12
|
import PromptGenerator from '../PromptGenerator.js';
|
|
13
|
-
export class
|
|
13
|
+
export class OpenAiAdapter {
|
|
14
14
|
constructor(apiKey) {
|
|
15
15
|
assertOptions({ apiKey }, ['apiKey']);
|
|
16
|
-
const config = new
|
|
17
|
-
this.api = new
|
|
16
|
+
const config = new OpenAiAdapter.Configuration({ apiKey });
|
|
17
|
+
this.api = new OpenAiAdapter.OpenAIApi(config);
|
|
18
18
|
}
|
|
19
19
|
sendMessage(bot) {
|
|
20
20
|
var _a, _b, _c;
|
|
@@ -24,13 +24,13 @@ export class OpenAi {
|
|
|
24
24
|
const response = yield this.api.createCompletion({
|
|
25
25
|
prompt,
|
|
26
26
|
model: 'text-davinci-003',
|
|
27
|
-
max_tokens:
|
|
27
|
+
max_tokens: 250,
|
|
28
28
|
stop: ['__Me__:'],
|
|
29
29
|
});
|
|
30
30
|
return ((_c = (_b = (_a = response.data.choices[0]) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : MESSAGE_RESPONSE_ERROR_MESSAGE);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
OpenAiAdapter.Configuration = Configuration;
|
|
35
|
+
OpenAiAdapter.OpenAIApi = OpenAIApi;
|
|
36
36
|
export const MESSAGE_RESPONSE_ERROR_MESSAGE = "Oh no! Something went wrong and I can't talk right now!";
|
package/build/esm/chat.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { stdin as input, stdout as output } from 'node:process';
|
|
11
11
|
import * as readline from 'node:readline/promises.js';
|
|
12
12
|
import dotenv from 'dotenv';
|
|
13
|
-
import {
|
|
13
|
+
import { OpenAiAdapter } from './bots/adapters/OpenAi.js';
|
|
14
14
|
import SprucebotLlmFactory from './bots/SprucebotLlmFactory.js';
|
|
15
15
|
import buildCallbackSkill from './examples/buildCallbackSkill.js';
|
|
16
16
|
import buildFileTransformerSkill from './examples/buildFileTransformerSkill.js';
|
|
@@ -20,7 +20,7 @@ dotenv.config();
|
|
|
20
20
|
const rl = readline.createInterface({ input, output });
|
|
21
21
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
console.clear();
|
|
23
|
-
const adapter = new
|
|
23
|
+
const adapter = new OpenAiAdapter(process.env.OPEN_AI_API_KEY);
|
|
24
24
|
const bots = SprucebotLlmFactory.Factory();
|
|
25
25
|
const skills = {
|
|
26
26
|
jokes: buildJokeSkill(bots),
|
|
@@ -30,7 +30,7 @@ const rl = readline.createInterface({ input, output });
|
|
|
30
30
|
};
|
|
31
31
|
const bot = bots.Bot({
|
|
32
32
|
adapter,
|
|
33
|
-
skill: skills.
|
|
33
|
+
skill: skills.profile,
|
|
34
34
|
youAre: "a bot named Sprucebot that is in test mode. At the start of every conversation, you introduce yourself and announce that you are in test mode so I don't get confused! You are both hip and adorable. You say things like, 'Jeepers' and 'Golly' or even 'Jeezey peezy'!",
|
|
35
35
|
});
|
|
36
36
|
do {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildCallbackSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildCallbackSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -10,6 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
export default function buildCallbackSkill(bots) {
|
|
11
11
|
return bots.Skill({
|
|
12
12
|
yourJobIfYouChooseToAcceptItIs: "to be be the best appointment taker on the planet. You have a many years of experience. You are going to ask me only 2 questions for this practice run. First, you'll ask me to pick an available time. Then, you'll ask me to pick my favorite color:",
|
|
13
|
+
pleaseKeepInMindThat: [
|
|
14
|
+
"getting a service is really important, so if i don't like any of the time, as to check another day or if i want to see a different provider",
|
|
15
|
+
],
|
|
13
16
|
callbacks: {
|
|
14
17
|
availableTimes: {
|
|
15
18
|
cb: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildFileTransformerSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildFileTransformerSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildJokeSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildJokeSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildProfileSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildProfileSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { default as SprucebotLlmFactory } from './bots/SprucebotLlmFactory.js';
|
|
2
|
+
export { OpenAiAdapter } from './bots/adapters/OpenAi.js';
|
|
3
|
+
export * from './llm.types.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildCallbackSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildCallbackSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
function buildCallbackSkill(bots) {
|
|
4
4
|
return bots.Skill({
|
|
5
5
|
yourJobIfYouChooseToAcceptItIs: "to be be the best appointment taker on the planet. You have a many years of experience. You are going to ask me only 2 questions for this practice run. First, you'll ask me to pick an available time. Then, you'll ask me to pick my favorite color:",
|
|
6
|
+
pleaseKeepInMindThat: [
|
|
7
|
+
"getting a service is really important, so if i don't like any of the time, as to check another day or if i want to see a different provider",
|
|
8
|
+
],
|
|
6
9
|
callbacks: {
|
|
7
10
|
availableTimes: {
|
|
8
11
|
cb: async () => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildFileTransformerSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildFileTransformerSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildJokeSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildJokeSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import SprucebotLlmFactory from '../bots/SprucebotLlmFactory';
|
|
2
|
-
export default function buildProfileSkill(bots: SprucebotLlmFactory): import("
|
|
2
|
+
export default function buildProfileSkill(bots: SprucebotLlmFactory): import("..").SprucebotLLmSkill<import("@sprucelabs/schema").Schema, import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/schema").Schema, false, never, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/schema").Schema, false>>>;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.OpenAiAdapter = exports.SprucebotLlmFactory = void 0;
|
|
21
|
+
var SprucebotLlmFactory_1 = require("./bots/SprucebotLlmFactory");
|
|
22
|
+
Object.defineProperty(exports, "SprucebotLlmFactory", { enumerable: true, get: function () { return __importDefault(SprucebotLlmFactory_1).default; } });
|
|
23
|
+
var OpenAi_1 = require("./bots/adapters/OpenAi");
|
|
24
|
+
Object.defineProperty(exports, "OpenAiAdapter", { enumerable: true, get: function () { return OpenAi_1.OpenAiAdapter; } });
|
|
25
|
+
__exportStar(require("./llm.types"), exports);
|