@bedrockio/ai 0.9.4 → 0.9.6
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/CHANGELOG.md +5 -0
- package/dist/cjs/BaseClient.js +16 -5
- package/dist/cjs/index.js +5 -1
- package/dist/esm/BaseClient.js +16 -5
- package/dist/esm/index.js +1 -0
- package/package.json +1 -1
- package/types/BaseClient.d.ts +1 -0
- package/types/BaseClient.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_fs_1 = require("node:fs");
|
|
3
4
|
const templates_1 = require("@bedrockio/templates");
|
|
4
5
|
const code_js_1 = require("./utils/code.js");
|
|
5
6
|
const json_js_1 = require("./utils/json.js");
|
|
@@ -13,6 +14,13 @@ class BaseClient {
|
|
|
13
14
|
this.renderer = new templates_1.TemplateRenderer({
|
|
14
15
|
dir: options.templates,
|
|
15
16
|
});
|
|
17
|
+
this.assertTemplatesDir();
|
|
18
|
+
}
|
|
19
|
+
assertTemplatesDir() {
|
|
20
|
+
const { templates } = this.options;
|
|
21
|
+
if (templates && !(0, node_fs_1.existsSync)(templates)) {
|
|
22
|
+
throw new Error(`Directory not found: ${templates}`);
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
// Public
|
|
18
26
|
/**
|
|
@@ -110,7 +118,8 @@ class BaseClient {
|
|
|
110
118
|
getFilteredMessages(options) {
|
|
111
119
|
const { messages = [] } = options;
|
|
112
120
|
return messages.filter((message) => {
|
|
113
|
-
|
|
121
|
+
const trimmed = message.content.trim();
|
|
122
|
+
return trimmed && trimmed !== '.';
|
|
114
123
|
});
|
|
115
124
|
}
|
|
116
125
|
// Protected
|
|
@@ -236,12 +245,14 @@ class BaseClient {
|
|
|
236
245
|
}
|
|
237
246
|
if (result.length === 1 && !result[0].content) {
|
|
238
247
|
// If a single user input is passed and is nullish, coerce it to a
|
|
239
|
-
// single
|
|
248
|
+
// single period. Combined with getFilteredMessages below this allows
|
|
240
249
|
// a chatbot the ability to "speak first" by prompting it with empty
|
|
241
250
|
// content. The empty message will be filtered out of the final result
|
|
242
|
-
// appearing as if the chatbot went first.
|
|
243
|
-
//
|
|
244
|
-
|
|
251
|
+
// appearing as if the chatbot went first.
|
|
252
|
+
// Note that:
|
|
253
|
+
// GPT will fail on an empty string but on whitespace
|
|
254
|
+
// Anthropic will fail on all whitespace
|
|
255
|
+
result[0].content = '.';
|
|
245
256
|
}
|
|
246
257
|
return result;
|
|
247
258
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,12 +3,16 @@ 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.McpServer = void 0;
|
|
6
|
+
exports.XAiClient = exports.OpenAiClient = exports.GoogleClient = exports.AnthropicClient = exports.McpServer = void 0;
|
|
7
7
|
exports.createClient = createClient;
|
|
8
8
|
const anthropic_js_1 = require("./anthropic.js");
|
|
9
|
+
Object.defineProperty(exports, "AnthropicClient", { enumerable: true, get: function () { return anthropic_js_1.AnthropicClient; } });
|
|
9
10
|
const google_js_1 = require("./google.js");
|
|
11
|
+
Object.defineProperty(exports, "GoogleClient", { enumerable: true, get: function () { return google_js_1.GoogleClient; } });
|
|
10
12
|
const openai_js_1 = require("./openai.js");
|
|
13
|
+
Object.defineProperty(exports, "OpenAiClient", { enumerable: true, get: function () { return openai_js_1.OpenAiClient; } });
|
|
11
14
|
const xai_js_1 = require("./xai.js");
|
|
15
|
+
Object.defineProperty(exports, "XAiClient", { enumerable: true, get: function () { return xai_js_1.XAiClient; } });
|
|
12
16
|
var McpServer_js_1 = require("./McpServer.js");
|
|
13
17
|
Object.defineProperty(exports, "McpServer", { enumerable: true, get: function () { return __importDefault(McpServer_js_1).default; } });
|
|
14
18
|
function createClient(options = {}) {
|
package/dist/esm/BaseClient.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import { TemplateRenderer } from '@bedrockio/templates';
|
|
2
3
|
import { parseCode } from './utils/code.js';
|
|
3
4
|
import { createMessageExtractor } from './utils/json.js';
|
|
@@ -11,6 +12,13 @@ export default class BaseClient {
|
|
|
11
12
|
this.renderer = new TemplateRenderer({
|
|
12
13
|
dir: options.templates,
|
|
13
14
|
});
|
|
15
|
+
this.assertTemplatesDir();
|
|
16
|
+
}
|
|
17
|
+
assertTemplatesDir() {
|
|
18
|
+
const { templates } = this.options;
|
|
19
|
+
if (templates && !existsSync(templates)) {
|
|
20
|
+
throw new Error(`Directory not found: ${templates}`);
|
|
21
|
+
}
|
|
14
22
|
}
|
|
15
23
|
// Public
|
|
16
24
|
/**
|
|
@@ -108,7 +116,8 @@ export default class BaseClient {
|
|
|
108
116
|
getFilteredMessages(options) {
|
|
109
117
|
const { messages = [] } = options;
|
|
110
118
|
return messages.filter((message) => {
|
|
111
|
-
|
|
119
|
+
const trimmed = message.content.trim();
|
|
120
|
+
return trimmed && trimmed !== '.';
|
|
112
121
|
});
|
|
113
122
|
}
|
|
114
123
|
// Protected
|
|
@@ -234,12 +243,14 @@ export default class BaseClient {
|
|
|
234
243
|
}
|
|
235
244
|
if (result.length === 1 && !result[0].content) {
|
|
236
245
|
// If a single user input is passed and is nullish, coerce it to a
|
|
237
|
-
// single
|
|
246
|
+
// single period. Combined with getFilteredMessages below this allows
|
|
238
247
|
// a chatbot the ability to "speak first" by prompting it with empty
|
|
239
248
|
// content. The empty message will be filtered out of the final result
|
|
240
|
-
// appearing as if the chatbot went first.
|
|
241
|
-
//
|
|
242
|
-
|
|
249
|
+
// appearing as if the chatbot went first.
|
|
250
|
+
// Note that:
|
|
251
|
+
// GPT will fail on an empty string but on whitespace
|
|
252
|
+
// Anthropic will fail on all whitespace
|
|
253
|
+
result[0].content = '.';
|
|
243
254
|
}
|
|
244
255
|
return result;
|
|
245
256
|
}
|
package/dist/esm/index.js
CHANGED
package/package.json
CHANGED
package/types/BaseClient.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAOA;IACE,0BAUC;IATC,aAIC;IACD,2BAEE;IAIJ,2BAKC;IAID;;;;;OAKG;IACH,gBAFW,aAAa,gBAiCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAED,uCAMC;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAIC;IAED;;OAEG;IACH,oDAIC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAeC;IAED,4CAiDC;IAED,uCAoCC;IAED;;;MA4BC;IAED,uDAWC;IAED,kDAMC;CACF;;;;;WAIa,MAAM;kBACN,MAAM;;;;cACN,aAAa,EAAE;;;;YACf,MAAM;;;;YACN,OAAO;;;;;;;;aAEP,MAAM,GAAG,MAAM;;;;;;;;;;;sBAOf,MAAM;;;UAKN,QAAQ,GAAG,MAAM,GAAG,WAAW;aAC/B,MAAM;;iCA1Xa,sBAAsB"}
|
package/types/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { default as McpServer } from "./McpServer.js";
|
|
|
3
3
|
import { AnthropicClient } from './anthropic.js';
|
|
4
4
|
import { GoogleClient } from './google.js';
|
|
5
5
|
import { OpenAiClient } from './openai.js';
|
|
6
|
+
import { XAiClient } from './xai.js';
|
|
7
|
+
export { AnthropicClient, GoogleClient, OpenAiClient, XAiClient };
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAMA,0FAkBC;;gCAxB+B,gBAAgB;6BACnB,aAAa;6BACb,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAMA,0FAkBC;;gCAxB+B,gBAAgB;6BACnB,aAAa;6BACb,aAAa;0BAChB,UAAU"}
|