@sprucelabs/sprucebot-llm 14.2.0 → 14.2.1

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.
@@ -1,10 +1,12 @@
1
+ import { Log } from '@sprucelabs/spruce-skill-utils';
1
2
  import { LlmAdapter } from '../../llm.types';
2
3
  export default class LlmAdapterLoaderImpl implements LlmAdapterLoader {
3
4
  static Class?: new (adapterName: ValidAdapterName) => LlmAdapterLoader;
4
5
  static VALID_ADAPTERS: string[];
5
6
  private adapterName;
6
- protected constructor(adapterName: ValidAdapterName);
7
- static Loader(): LlmAdapterLoader;
7
+ private log?;
8
+ protected constructor(adapterName: ValidAdapterName, log?: Log);
9
+ static Loader(log?: Log): LlmAdapterLoader;
8
10
  Adapter(): LlmAdapter;
9
11
  private constructorsByName;
10
12
  }
@@ -9,13 +9,14 @@ const AnthropicAdapter_1 = __importDefault(require("./AnthropicAdapter"));
9
9
  const OllamaAdapter_1 = __importDefault(require("./OllamaAdapter"));
10
10
  const OpenAiAdapter_1 = __importDefault(require("./OpenAiAdapter"));
11
11
  class LlmAdapterLoaderImpl {
12
- constructor(adapterName) {
12
+ constructor(adapterName, log) {
13
13
  this.constructorsByName = {
14
14
  openai: (key, options) => {
15
15
  return OpenAiAdapter_1.default.Adapter(key, {
16
16
  ...options,
17
17
  reasoningEffort: process.env
18
18
  .SPRUCE_LLM_REASONING_EFFORT,
19
+ log: this.log?.buildLog('OpenAiAdapter'),
19
20
  });
20
21
  },
21
22
  anthropic: (key, options) => {
@@ -23,18 +24,21 @@ class LlmAdapterLoaderImpl {
23
24
  ...options,
24
25
  thinking: process.env.SPRUCE_LLM_THINKING === 'true',
25
26
  maxTokens: parseInt(process.env.SPRUCE_LLM_MAX_TOKENS, 10),
27
+ log: this.log?.buildLog('AnthropicAdapter'),
26
28
  });
27
29
  },
28
30
  ollama: (_key, options) => {
29
31
  return OllamaAdapter_1.default.Adapter({
30
32
  ...options,
31
33
  think: process.env.SPRUCE_LLM_THINKING === 'true',
34
+ log: this.log?.buildLog('OllamaAdapter'),
32
35
  });
33
36
  },
34
37
  };
35
38
  this.adapterName = adapterName;
39
+ this.log = log;
36
40
  }
37
- static Loader() {
41
+ static Loader(log) {
38
42
  const { env: { SPRUCE_LLM_ADAPTER }, } = (0, schema_1.assertOptions)({
39
43
  env: process.env,
40
44
  }, ['env.SPRUCE_LLM_ADAPTER']);
@@ -50,7 +54,7 @@ class LlmAdapterLoaderImpl {
50
54
  env: process.env,
51
55
  }, ['env.SPRUCE_LLM_MAX_TOKENS']);
52
56
  }
53
- return new (this.Class ?? this)(name);
57
+ return new (this.Class ?? this)(name, log);
54
58
  }
55
59
  Adapter() {
56
60
  const key = process.env.SPRUCE_LLM_API_KEY;
@@ -1,10 +1,12 @@
1
+ import { Log } from '@sprucelabs/spruce-skill-utils';
1
2
  import { LlmAdapter } from '../../llm.types';
2
3
  export default class LlmAdapterLoaderImpl implements LlmAdapterLoader {
3
4
  static Class?: new (adapterName: ValidAdapterName) => LlmAdapterLoader;
4
5
  static VALID_ADAPTERS: string[];
5
6
  private adapterName;
6
- protected constructor(adapterName: ValidAdapterName);
7
- static Loader(): LlmAdapterLoader;
7
+ private log?;
8
+ protected constructor(adapterName: ValidAdapterName, log?: Log);
9
+ static Loader(log?: Log): LlmAdapterLoader;
8
10
  Adapter(): LlmAdapter;
9
11
  private constructorsByName;
10
12
  }
@@ -4,22 +4,26 @@ import AnthropicAdapter from './AnthropicAdapter.js';
4
4
  import OllamaAdapter from './OllamaAdapter.js';
5
5
  import OpenAiAdapter from './OpenAiAdapter.js';
6
6
  class LlmAdapterLoaderImpl {
7
- constructor(adapterName) {
7
+ constructor(adapterName, log) {
8
8
  this.constructorsByName = {
9
9
  openai: (key, options) => {
10
+ var _a;
10
11
  return OpenAiAdapter.Adapter(key, Object.assign(Object.assign({}, options), { reasoningEffort: process.env
11
- .SPRUCE_LLM_REASONING_EFFORT }));
12
+ .SPRUCE_LLM_REASONING_EFFORT, log: (_a = this.log) === null || _a === void 0 ? void 0 : _a.buildLog('OpenAiAdapter') }));
12
13
  },
13
14
  anthropic: (key, options) => {
14
- return AnthropicAdapter.Adapter(key, Object.assign(Object.assign({}, options), { thinking: process.env.SPRUCE_LLM_THINKING === 'true', maxTokens: parseInt(process.env.SPRUCE_LLM_MAX_TOKENS, 10) }));
15
+ var _a;
16
+ return AnthropicAdapter.Adapter(key, Object.assign(Object.assign({}, options), { thinking: process.env.SPRUCE_LLM_THINKING === 'true', maxTokens: parseInt(process.env.SPRUCE_LLM_MAX_TOKENS, 10), log: (_a = this.log) === null || _a === void 0 ? void 0 : _a.buildLog('AnthropicAdapter') }));
15
17
  },
16
18
  ollama: (_key, options) => {
17
- return OllamaAdapter.Adapter(Object.assign(Object.assign({}, options), { think: process.env.SPRUCE_LLM_THINKING === 'true' }));
19
+ var _a;
20
+ return OllamaAdapter.Adapter(Object.assign(Object.assign({}, options), { think: process.env.SPRUCE_LLM_THINKING === 'true', log: (_a = this.log) === null || _a === void 0 ? void 0 : _a.buildLog('OllamaAdapter') }));
18
21
  },
19
22
  };
20
23
  this.adapterName = adapterName;
24
+ this.log = log;
21
25
  }
22
- static Loader() {
26
+ static Loader(log) {
23
27
  var _a;
24
28
  const { env: { SPRUCE_LLM_ADAPTER }, } = assertOptions({
25
29
  env: process.env,
@@ -36,7 +40,7 @@ class LlmAdapterLoaderImpl {
36
40
  env: process.env,
37
41
  }, ['env.SPRUCE_LLM_MAX_TOKENS']);
38
42
  }
39
- return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(name);
43
+ return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(name, log);
40
44
  }
41
45
  Adapter() {
42
46
  const key = process.env.SPRUCE_LLM_API_KEY;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "14.2.0",
11
+ "version": "14.2.1",
12
12
  "files": [
13
13
  "build"
14
14
  ],