@sprucelabs/sprucebot-llm 13.2.3 → 13.2.4

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.
@@ -10,6 +10,7 @@ export default class AnthropicAdapter implements LlmAdapter {
10
10
  private sender;
11
11
  private memoryLimit?;
12
12
  private isThinkingEnabled;
13
+ private log?;
13
14
  constructor(apiKey: string, options: AnthropicAdapterOptions);
14
15
  sendMessage(bot: SprucebotLlmBot<Schema>, options?: SendMessageOptions): Promise<string>;
15
16
  private sendHandler;
@@ -19,6 +19,7 @@ class AnthropicAdapter {
19
19
  this.maxTokens = maxTokens;
20
20
  this.memoryLimit = memoryLimit;
21
21
  this.isThinkingEnabled = thinking ?? false;
22
+ this.log = log?.buildLog('AnthropicAdapter');
22
23
  this.sender = MessageSender_1.default.Sender(this.sendHandler.bind(this), log);
23
24
  }
24
25
  async sendMessage(bot, options) {
@@ -46,7 +47,12 @@ class AnthropicAdapter {
46
47
  type: this.isThinkingEnabled ? 'adaptive' : 'disabled',
47
48
  },
48
49
  }, sendOptions);
49
- const text = response.content.find((block) => block.type === 'text')?.text;
50
+ this.log?.info('Received response from Anthropic', JSON.stringify(response, null, 2));
51
+ const text = response.content
52
+ .filter((block) => block.type === 'text')
53
+ ?.map((block) => block.text)
54
+ .join('')
55
+ .trim();
50
56
  return text;
51
57
  }
52
58
  setModel(model) {
@@ -10,6 +10,7 @@ export default class AnthropicAdapter implements LlmAdapter {
10
10
  private sender;
11
11
  private memoryLimit?;
12
12
  private isThinkingEnabled;
13
+ private log?;
13
14
  constructor(apiKey: string, options: AnthropicAdapterOptions);
14
15
  sendMessage(bot: SprucebotLlmBot<Schema>, options?: SendMessageOptions): Promise<string>;
15
16
  private sendHandler;
@@ -23,6 +23,7 @@ class AnthropicAdapter {
23
23
  this.maxTokens = maxTokens;
24
24
  this.memoryLimit = memoryLimit;
25
25
  this.isThinkingEnabled = thinking !== null && thinking !== void 0 ? thinking : false;
26
+ this.log = log === null || log === void 0 ? void 0 : log.buildLog('AnthropicAdapter');
26
27
  this.sender = MessageSenderImpl.Sender(this.sendHandler.bind(this), log);
27
28
  }
28
29
  sendMessage(bot, options) {
@@ -33,7 +34,7 @@ class AnthropicAdapter {
33
34
  }
34
35
  sendHandler(params, sendOptions) {
35
36
  return __awaiter(this, void 0, void 0, function* () {
36
- var _a;
37
+ var _a, _b;
37
38
  const { messages: openAiMessages, model } = params;
38
39
  const messages = [];
39
40
  for (const msg of openAiMessages) {
@@ -50,7 +51,9 @@ class AnthropicAdapter {
50
51
  type: this.isThinkingEnabled ? 'adaptive' : 'disabled',
51
52
  },
52
53
  }, sendOptions);
53
- const text = (_a = response.content.find((block) => block.type === 'text')) === null || _a === void 0 ? void 0 : _a.text;
54
+ (_a = this.log) === null || _a === void 0 ? void 0 : _a.info('Received response from Anthropic', JSON.stringify(response, null, 2));
55
+ const text = (_b = response.content
56
+ .filter((block) => block.type === 'text')) === null || _b === void 0 ? void 0 : _b.map((block) => block.text).join('').trim();
54
57
  return text;
55
58
  });
56
59
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "13.2.3",
11
+ "version": "13.2.4",
12
12
  "files": [
13
13
  "build"
14
14
  ],