@sprucelabs/sprucebot-llm 0.0.4 → 1.0.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 +7 -7
- package/build/bots/adapters/SpyOpenAiApi.js +1 -1
- package/build/chat.js +1 -1
- package/build/esm/bots/adapters/OpenAi.d.ts +1 -1
- package/build/esm/bots/adapters/OpenAi.js +6 -5
- package/build/esm/bots/adapters/SpyOpenAiApi.js +2 -1
- package/build/esm/chat.js +2 -2
- package/build/esm/examples/buildCallbackSkill.d.ts +1 -1
- 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/esm/parsingResponses/ResponseParser.js +2 -1
- package/build/examples/buildCallbackSkill.d.ts +1 -1
- 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/build/parsingResponses/ResponseParser.js +1 -1
- package/package.json +18 -18
|
@@ -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;
|
|
@@ -26,7 +26,7 @@ class OpenAi {
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
OpenAiAdapter.Configuration = openai_1.Configuration;
|
|
30
|
+
OpenAiAdapter.OpenAIApi = openai_1.OpenAIApi;
|
|
31
|
+
exports.OpenAiAdapter = OpenAiAdapter;
|
|
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),
|
|
@@ -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
|
-
|
|
13
|
+
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;
|
|
@@ -31,6 +31,7 @@ export class OpenAi {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
OpenAiAdapter.Configuration = Configuration;
|
|
35
|
+
OpenAiAdapter.OpenAIApi = OpenAIApi;
|
|
36
|
+
export { OpenAiAdapter };
|
|
36
37
|
export const MESSAGE_RESPONSE_ERROR_MESSAGE = "Oh no! Something went wrong and I can't talk right now!";
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { OpenAIApi, } from 'openai';
|
|
11
|
-
|
|
11
|
+
class SpyOpenAiApi extends OpenAIApi {
|
|
12
12
|
constructor(config) {
|
|
13
13
|
super(config);
|
|
14
14
|
SpyOpenAiApi.config = config;
|
|
@@ -40,3 +40,4 @@ export default class SpyOpenAiApi extends OpenAIApi {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
SpyOpenAiApi.responseMessage = 'hello!';
|
|
43
|
+
export default SpyOpenAiApi;
|
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),
|
|
@@ -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>>>;
|
|
@@ -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';
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { DONE_TOKEN, STATE_BOUNDARY } from '../bots/templates.js';
|
|
11
11
|
import renderPlaceholder from './renderPlaceholder.js';
|
|
12
|
-
|
|
12
|
+
class ResponseParser {
|
|
13
13
|
static setInstance(parser) {
|
|
14
14
|
this.instance = parser;
|
|
15
15
|
}
|
|
@@ -58,3 +58,4 @@ export default class ResponseParser {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
ResponseParser.instance = new ResponseParser();
|
|
61
|
+
export default ResponseParser;
|
|
@@ -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>>>;
|
|
@@ -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);
|
|
@@ -49,5 +49,5 @@ class ResponseParser {
|
|
|
49
49
|
return { match, fullMatch: stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[0] };
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
exports.default = ResponseParser;
|
|
53
52
|
ResponseParser.instance = new ResponseParser();
|
|
53
|
+
exports.default = ResponseParser;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"@sprucelabs/spruce-test-fixtures"
|
|
10
10
|
]
|
|
11
11
|
},
|
|
12
|
-
"version": "0.0
|
|
12
|
+
"version": "1.0.0",
|
|
13
13
|
"files": [
|
|
14
14
|
"build"
|
|
15
15
|
],
|
|
@@ -53,32 +53,32 @@
|
|
|
53
53
|
"chat": "node ./build/chat.js"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@sprucelabs/error": "^5.0.
|
|
57
|
-
"@sprucelabs/mercury-event-emitter": "^
|
|
58
|
-
"@sprucelabs/mercury-types": "^
|
|
59
|
-
"@sprucelabs/schema": "^28.5.
|
|
60
|
-
"eta": "^2.0.
|
|
61
|
-
"openai": "^3.1
|
|
56
|
+
"@sprucelabs/error": "^5.0.592",
|
|
57
|
+
"@sprucelabs/mercury-event-emitter": "^38.0.34",
|
|
58
|
+
"@sprucelabs/mercury-types": "^42.1.22",
|
|
59
|
+
"@sprucelabs/schema": "^28.5.155",
|
|
60
|
+
"eta": "^2.0.1",
|
|
61
|
+
"openai": "^3.2.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@sprucelabs/esm-postbuild": "^
|
|
65
|
-
"@sprucelabs/jest-json-reporter": "^
|
|
66
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
64
|
+
"@sprucelabs/esm-postbuild": "^3.0.15",
|
|
65
|
+
"@sprucelabs/jest-json-reporter": "^7.0.13",
|
|
66
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.201",
|
|
67
67
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
68
|
-
"@sprucelabs/test": "^7.7.
|
|
69
|
-
"@sprucelabs/test-utils": "^3.
|
|
70
|
-
"@types/node": "^18.
|
|
68
|
+
"@sprucelabs/test": "^7.7.431",
|
|
69
|
+
"@sprucelabs/test-utils": "^3.4.26",
|
|
70
|
+
"@types/node": "^18.15.5",
|
|
71
71
|
"chokidar-cli": "^3.0.0",
|
|
72
72
|
"concurrently": "^7.6.0",
|
|
73
73
|
"dotenv": "^16.0.3",
|
|
74
|
-
"eslint": "^8.
|
|
74
|
+
"eslint": "^8.36.0",
|
|
75
75
|
"eslint-config-spruce": "^10.12.0",
|
|
76
|
-
"jest": "^29.
|
|
77
|
-
"jest-circus": "^29.
|
|
78
|
-
"prettier": "^2.8.
|
|
76
|
+
"jest": "^29.5.0",
|
|
77
|
+
"jest-circus": "^29.5.0",
|
|
78
|
+
"prettier": "^2.8.6",
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"tsc-watch": "^6.0.0",
|
|
81
|
-
"typescript": "^
|
|
81
|
+
"typescript": "^5.0.2"
|
|
82
82
|
},
|
|
83
83
|
"jest": {
|
|
84
84
|
"testRunner": "jest-circus/runner",
|