@blockrun/llm 3.5.1 → 3.6.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.
- package/dist/index.cjs +14 -10
- package/dist/index.js +10 -6
- package/package.json +12 -5
package/dist/index.cjs
CHANGED
|
@@ -132,9 +132,6 @@ var APIError = class extends BlockrunError {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
// src/client.ts
|
|
136
|
-
var import_clawrouter = require("@blockrun/clawrouter");
|
|
137
|
-
|
|
138
135
|
// src/x402.ts
|
|
139
136
|
var import_accounts = require("viem/accounts");
|
|
140
137
|
var BASE_CHAIN_ID = 8453;
|
|
@@ -653,13 +650,23 @@ var LLMClient = class _LLMClient {
|
|
|
653
650
|
async smartChat(prompt, options) {
|
|
654
651
|
const modelPricing = await this.getModelPricing();
|
|
655
652
|
const maxOutputTokens = options?.maxOutputTokens || options?.maxTokens || 1024;
|
|
656
|
-
|
|
657
|
-
|
|
653
|
+
let route;
|
|
654
|
+
let DEFAULT_ROUTING_CONFIG;
|
|
655
|
+
let getFallbackChain;
|
|
656
|
+
try {
|
|
657
|
+
({ route, DEFAULT_ROUTING_CONFIG, getFallbackChain } = await import("@blockrun/clawrouter"));
|
|
658
|
+
} catch (err) {
|
|
659
|
+
throw new Error(
|
|
660
|
+
`smartChat() requires the optional '@blockrun/clawrouter' routing engine, which is not installed or failed to load. Install it, or call chat() with an explicit model instead. Cause: ${err.message}`
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
const decision = route(prompt, options?.system, maxOutputTokens, {
|
|
664
|
+
config: DEFAULT_ROUTING_CONFIG,
|
|
658
665
|
modelPricing,
|
|
659
666
|
routingProfile: options?.routingProfile
|
|
660
667
|
});
|
|
661
|
-
const tierConfigs = decision.tierConfigs ??
|
|
662
|
-
const fullChain =
|
|
668
|
+
const tierConfigs = decision.tierConfigs ?? DEFAULT_ROUTING_CONFIG.tiers;
|
|
669
|
+
const fullChain = getFallbackChain(decision.tier, tierConfigs);
|
|
663
670
|
const fallbacks = fullChain.filter(
|
|
664
671
|
(id) => id !== decision.model && modelPricing.has(id)
|
|
665
672
|
);
|
|
@@ -5745,9 +5752,6 @@ var ChatCompletions = class {
|
|
|
5745
5752
|
this.apiUrl = apiUrl;
|
|
5746
5753
|
this.timeout = timeout;
|
|
5747
5754
|
}
|
|
5748
|
-
client;
|
|
5749
|
-
apiUrl;
|
|
5750
|
-
timeout;
|
|
5751
5755
|
async create(params) {
|
|
5752
5756
|
if (params.stream) {
|
|
5753
5757
|
return this.createStream(params);
|
package/dist/index.js
CHANGED
|
@@ -25,9 +25,6 @@ var APIError = class extends BlockrunError {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
// src/client.ts
|
|
29
|
-
import { route, DEFAULT_ROUTING_CONFIG, getFallbackChain } from "@blockrun/clawrouter";
|
|
30
|
-
|
|
31
28
|
// src/x402.ts
|
|
32
29
|
import { signTypedData } from "viem/accounts";
|
|
33
30
|
var BASE_CHAIN_ID = 8453;
|
|
@@ -546,6 +543,16 @@ var LLMClient = class _LLMClient {
|
|
|
546
543
|
async smartChat(prompt, options) {
|
|
547
544
|
const modelPricing = await this.getModelPricing();
|
|
548
545
|
const maxOutputTokens = options?.maxOutputTokens || options?.maxTokens || 1024;
|
|
546
|
+
let route;
|
|
547
|
+
let DEFAULT_ROUTING_CONFIG;
|
|
548
|
+
let getFallbackChain;
|
|
549
|
+
try {
|
|
550
|
+
({ route, DEFAULT_ROUTING_CONFIG, getFallbackChain } = await import("@blockrun/clawrouter"));
|
|
551
|
+
} catch (err) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
`smartChat() requires the optional '@blockrun/clawrouter' routing engine, which is not installed or failed to load. Install it, or call chat() with an explicit model instead. Cause: ${err.message}`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
549
556
|
const decision = route(prompt, options?.system, maxOutputTokens, {
|
|
550
557
|
config: DEFAULT_ROUTING_CONFIG,
|
|
551
558
|
modelPricing,
|
|
@@ -5638,9 +5645,6 @@ var ChatCompletions = class {
|
|
|
5638
5645
|
this.apiUrl = apiUrl;
|
|
5639
5646
|
this.timeout = timeout;
|
|
5640
5647
|
}
|
|
5641
|
-
client;
|
|
5642
|
-
apiUrl;
|
|
5643
|
-
timeout;
|
|
5644
5648
|
async create(params) {
|
|
5645
5649
|
if (params.stream) {
|
|
5646
5650
|
return this.createStream(params);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/llm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BlockRun SDK - Pay-per-request AI (LLM, Image, Video, Music, Voice) via x402 on Base and Solana",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external @anthropic-ai/sdk --external @solana/web3.js --external @solana/spl-token --external bs58",
|
|
22
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external @anthropic-ai/sdk --external @solana/web3.js --external @solana/spl-token --external bs58",
|
|
21
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external @blockrun/clawrouter --external @anthropic-ai/sdk --external @solana/web3.js --external @solana/spl-token --external bs58",
|
|
22
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external @blockrun/clawrouter --external @anthropic-ai/sdk --external @solana/web3.js --external @solana/spl-token --external bs58",
|
|
23
23
|
"test": "vitest",
|
|
24
24
|
"lint": "eslint src/",
|
|
25
25
|
"typecheck": "tsc --noEmit"
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"url": "https://github.com/BlockRunAI/blockrun-llm-ts/issues"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@blockrun/clawrouter": "^0.12.190",
|
|
52
51
|
"bs58": "^6.0.0",
|
|
53
52
|
"viem": "^2.49.0"
|
|
54
53
|
},
|
|
@@ -76,5 +75,13 @@
|
|
|
76
75
|
"engines": {
|
|
77
76
|
"node": ">=20"
|
|
78
77
|
},
|
|
79
|
-
"packageManager": "pnpm@9.15.4"
|
|
78
|
+
"packageManager": "pnpm@9.15.4",
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"@blockrun/clawrouter": "^0.12.222"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"@blockrun/clawrouter": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
80
87
|
}
|