@botpress/cognitive 0.1.21 → 0.1.23
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/.turbo/turbo-build.log +15 -28
- package/.turbo/turbo-generate.log +5 -0
- package/bp_modules/llm/definition/actions/generateContent/index.ts +14 -0
- package/bp_modules/llm/definition/actions/generateContent/input.ts +133 -0
- package/bp_modules/llm/definition/actions/generateContent/output.ts +81 -0
- package/bp_modules/llm/definition/actions/index.ts +12 -0
- package/bp_modules/llm/definition/actions/listLanguageModels/index.ts +14 -0
- package/bp_modules/llm/definition/actions/listLanguageModels/input.ts +8 -0
- package/bp_modules/llm/definition/actions/listLanguageModels/output.ts +45 -0
- package/bp_modules/llm/definition/channels/index.ts +6 -0
- package/bp_modules/llm/definition/entities/index.ts +9 -0
- package/bp_modules/llm/definition/entities/modelRef.ts +10 -0
- package/bp_modules/llm/definition/events/index.ts +6 -0
- package/bp_modules/llm/definition/index.ts +23 -0
- package/bp_modules/llm/index.ts +16 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +196 -1495
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +2 -2
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
> @botpress/cognitive@0.1.21 build:neutral /home/runner/work/botpress/botpress/packages/cognitive
|
|
17
|
-
> ts-node -T ./build.ts --neutral
|
|
18
|
-
|
|
19
|
-
Done
|
|
20
|
-
|
|
21
|
-
[1mdist/index.cjs[22m
|
|
22
|
-
Size limit: [32m[1m50 kB[22m[39m
|
|
23
|
-
Size: [32m[1m6.91 kB[22m[39m [90mbrotlied[39m
|
|
24
|
-
|
|
25
|
-
[1mdist/index.mjs[22m
|
|
26
|
-
Size limit: [32m[1m50 kB[22m[39m
|
|
27
|
-
Size: [32m[1m6.79 kB[22m[39m [90mbrotlied[39m
|
|
28
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @botpress/cognitive@0.1.16 build /Users/sly/botpress/packages/cognitive
|
|
4
|
+
> pnpm build:type && pnpm build:neutral && size-limit
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
> @botpress/cognitive@0.1.16 build:type /Users/sly/botpress/packages/cognitive
|
|
8
|
+
> tsup --tsconfig tsconfig.build.json ./src/index.ts --dts-resolve --dts-only --clean
|
|
9
|
+
|
|
10
|
+
[34mCLI[39m Building entry: ./src/index.ts
|
|
11
|
+
[34mCLI[39m Using tsconfig: tsconfig.build.json
|
|
12
|
+
[34mCLI[39m tsup v8.0.2
|
|
13
|
+
[34mDTS[39m Build start
|
|
14
|
+
[41m[30m ELIFECYCLE [39m[49m [31mCommand failed.[39m
|
|
15
|
+
[41m[30m ELIFECYCLE [39m[49m [31mCommand failed.[39m
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
import * as input from "./input";
|
|
5
|
+
export * as input from "./input";
|
|
6
|
+
import * as output from "./output";
|
|
7
|
+
export * as output from "./output";
|
|
8
|
+
|
|
9
|
+
export const generateContent = {
|
|
10
|
+
"input": input.input,
|
|
11
|
+
"output": output.output,
|
|
12
|
+
"billable": true,
|
|
13
|
+
"cacheable": true,
|
|
14
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
|
|
5
|
+
import { z } from "@botpress/sdk";
|
|
6
|
+
export const input = {
|
|
7
|
+
schema: z.object({
|
|
8
|
+
model: /** Model to use for content generation */ z.optional(
|
|
9
|
+
/** Model to use for content generation */ z.ref("modelRef"),
|
|
10
|
+
),
|
|
11
|
+
reasoningEffort:
|
|
12
|
+
/** Reasoning effort level to use for models that support reasoning */ z.optional(
|
|
13
|
+
/** Reasoning effort level to use for models that support reasoning */ z.enum(
|
|
14
|
+
["low", "medium", "high"],
|
|
15
|
+
),
|
|
16
|
+
),
|
|
17
|
+
systemPrompt: /** Optional system prompt to guide the model */ z.optional(
|
|
18
|
+
/** Optional system prompt to guide the model */ z.string(),
|
|
19
|
+
),
|
|
20
|
+
messages: z.array(
|
|
21
|
+
z.object({
|
|
22
|
+
role: z.enum(["user", "assistant"]),
|
|
23
|
+
type: z
|
|
24
|
+
.enum(["text", "tool_calls", "tool_result", "multipart"])
|
|
25
|
+
.default("text"),
|
|
26
|
+
toolCalls: /** Required if `type` is "tool_calls" */ z.optional(
|
|
27
|
+
z.array(
|
|
28
|
+
z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
type: z.literal("function"),
|
|
31
|
+
function: z.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
arguments:
|
|
34
|
+
/** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */ z.union(
|
|
35
|
+
[z.record(z.string(), z.any()), z.null()],
|
|
36
|
+
),
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
toolResultCallId: /** Required if `type` is "tool_result" */ z.optional(
|
|
42
|
+
/** Required if `type` is "tool_result" */ z.string(),
|
|
43
|
+
),
|
|
44
|
+
content:
|
|
45
|
+
/** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */ z.union(
|
|
46
|
+
[
|
|
47
|
+
z.union([
|
|
48
|
+
z.string(),
|
|
49
|
+
z.array(
|
|
50
|
+
z.object({
|
|
51
|
+
type: z.enum(["text", "image"]),
|
|
52
|
+
mimeType:
|
|
53
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */ z.optional(
|
|
54
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */ z.string(),
|
|
55
|
+
),
|
|
56
|
+
text: /** Required if part type is "text" */ z.optional(
|
|
57
|
+
/** Required if part type is "text" */ z.string(),
|
|
58
|
+
),
|
|
59
|
+
url: /** Required if part type is "image" */ z.optional(
|
|
60
|
+
/** Required if part type is "image" */ z.string(),
|
|
61
|
+
),
|
|
62
|
+
}),
|
|
63
|
+
),
|
|
64
|
+
]),
|
|
65
|
+
z.null(),
|
|
66
|
+
],
|
|
67
|
+
),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
responseFormat:
|
|
71
|
+
/** Response format expected from the model. If "json_object" is chosen, you must instruct the model to generate JSON either via the system prompt or a user message. */ z.optional(
|
|
72
|
+
/** Response format expected from the model. If "json_object" is chosen, you must instruct the model to generate JSON either via the system prompt or a user message. */ z.enum(
|
|
73
|
+
["text", "json_object"],
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
maxTokens:
|
|
77
|
+
/** Maximum number of tokens allowed in the generated response */ z.optional(
|
|
78
|
+
/** Maximum number of tokens allowed in the generated response */ z.number(),
|
|
79
|
+
),
|
|
80
|
+
temperature:
|
|
81
|
+
/** Sampling temperature for the model. Higher values result in more random outputs. */ /** Sampling temperature for the model. Higher values result in more random outputs. */ z
|
|
82
|
+
.number()
|
|
83
|
+
.default(1),
|
|
84
|
+
topP: /** Top-p sampling parameter. Limits sampling to the smallest set of tokens with a cumulative probability above the threshold. */ /** Top-p sampling parameter. Limits sampling to the smallest set of tokens with a cumulative probability above the threshold. */ z
|
|
85
|
+
.number()
|
|
86
|
+
.default(1),
|
|
87
|
+
stopSequences:
|
|
88
|
+
/** Sequences where the model should stop generating further tokens. */ z.optional(
|
|
89
|
+
z.array(z.string()),
|
|
90
|
+
),
|
|
91
|
+
tools: z.optional(
|
|
92
|
+
z.array(
|
|
93
|
+
z.object({
|
|
94
|
+
type: z.literal("function"),
|
|
95
|
+
function: z.object({
|
|
96
|
+
name: /** Function name */ z.string(),
|
|
97
|
+
description: z.optional(z.string()),
|
|
98
|
+
argumentsSchema:
|
|
99
|
+
/** JSON schema of the function arguments */ z.optional(
|
|
100
|
+
/** JSON schema of the function arguments */ z.object({}),
|
|
101
|
+
),
|
|
102
|
+
}),
|
|
103
|
+
}),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
toolChoice: z.optional(
|
|
107
|
+
z.object({
|
|
108
|
+
type: z.optional(z.enum(["auto", "specific", "any", "none", ""])),
|
|
109
|
+
functionName: /** Required if `type` is "specific" */ z.optional(
|
|
110
|
+
/** Required if `type` is "specific" */ z.string(),
|
|
111
|
+
),
|
|
112
|
+
}),
|
|
113
|
+
),
|
|
114
|
+
userId: z.optional(z.string()),
|
|
115
|
+
debug:
|
|
116
|
+
/** Set to `true` to output debug information to the bot logs */ z.optional(
|
|
117
|
+
/** Set to `true` to output debug information to the bot logs */ z.boolean(),
|
|
118
|
+
),
|
|
119
|
+
meta: z.optional(
|
|
120
|
+
z.object({
|
|
121
|
+
promptSource:
|
|
122
|
+
/** Source of the prompt, e.g. agent/:id/:version cards/ai-generate, cards/ai-task, nodes/autonomous, etc. */ z.optional(
|
|
123
|
+
/** Source of the prompt, e.g. agent/:id/:version cards/ai-generate, cards/ai-task, nodes/autonomous, etc. */ z.string(),
|
|
124
|
+
),
|
|
125
|
+
promptCategory: z.optional(z.string()),
|
|
126
|
+
integrationName:
|
|
127
|
+
/** Name of the integration that originally received the message that initiated this action */ z.optional(
|
|
128
|
+
/** Name of the integration that originally received the message that initiated this action */ z.string(),
|
|
129
|
+
),
|
|
130
|
+
}),
|
|
131
|
+
),
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
|
|
5
|
+
import { z } from "@botpress/sdk";
|
|
6
|
+
export const output = {
|
|
7
|
+
schema: z.object({
|
|
8
|
+
id: /** Response ID from LLM provider */ z.string(),
|
|
9
|
+
provider: /** LLM provider name */ z.string(),
|
|
10
|
+
model: /** Model name */ z.string(),
|
|
11
|
+
choices: z.array(
|
|
12
|
+
z.object({
|
|
13
|
+
type: z
|
|
14
|
+
.enum(["text", "tool_calls", "tool_result", "multipart"])
|
|
15
|
+
.default("text"),
|
|
16
|
+
toolCalls: /** Required if `type` is "tool_calls" */ z.optional(
|
|
17
|
+
z.array(
|
|
18
|
+
z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
type: z.literal("function"),
|
|
21
|
+
function: z.object({
|
|
22
|
+
name: z.string(),
|
|
23
|
+
arguments:
|
|
24
|
+
/** Some LLMs may generate invalid JSON for a tool call, so this will be `null` when it happens. */ z.union(
|
|
25
|
+
[z.record(z.string(), z.any()), z.null()],
|
|
26
|
+
),
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
toolResultCallId: /** Required if `type` is "tool_result" */ z.optional(
|
|
32
|
+
/** Required if `type` is "tool_result" */ z.string(),
|
|
33
|
+
),
|
|
34
|
+
content:
|
|
35
|
+
/** Required unless `type` is "tool_call". If `type` is "multipart", this field must be an array of content objects. If `type` is "tool_result" then this field should be the result of the tool call (a plain string or a JSON-encoded array or object). If `type` is "tool_call" then the `toolCalls` field should be used instead. */ z.union(
|
|
36
|
+
[
|
|
37
|
+
z.union([
|
|
38
|
+
z.string(),
|
|
39
|
+
z.array(
|
|
40
|
+
z.object({
|
|
41
|
+
type: z.enum(["text", "image"]),
|
|
42
|
+
mimeType:
|
|
43
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */ z.optional(
|
|
44
|
+
/** Indicates the MIME type of the content. If not provided it will be detected from the content-type header of the provided URL. */ z.string(),
|
|
45
|
+
),
|
|
46
|
+
text: /** Required if part type is "text" */ z.optional(
|
|
47
|
+
/** Required if part type is "text" */ z.string(),
|
|
48
|
+
),
|
|
49
|
+
url: /** Required if part type is "image" */ z.optional(
|
|
50
|
+
/** Required if part type is "image" */ z.string(),
|
|
51
|
+
),
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
]),
|
|
55
|
+
z.null(),
|
|
56
|
+
],
|
|
57
|
+
),
|
|
58
|
+
role: z.literal("assistant"),
|
|
59
|
+
index: z.number(),
|
|
60
|
+
stopReason: z.enum([
|
|
61
|
+
"stop",
|
|
62
|
+
"max_tokens",
|
|
63
|
+
"tool_calls",
|
|
64
|
+
"content_filter",
|
|
65
|
+
"other",
|
|
66
|
+
]),
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
usage: z.object({
|
|
70
|
+
inputTokens: /** Number of input tokens used by the model */ z.number(),
|
|
71
|
+
inputCost:
|
|
72
|
+
/** Cost of the input tokens received by the model, in U.S. dollars */ z.number(),
|
|
73
|
+
outputTokens: /** Number of output tokens used by the model */ z.number(),
|
|
74
|
+
outputCost:
|
|
75
|
+
/** Cost of the output tokens generated by the model, in U.S. dollars */ z.number(),
|
|
76
|
+
}),
|
|
77
|
+
botpress: z.object({
|
|
78
|
+
cost: /** Total cost of the content generation, in U.S. dollars */ z.number(),
|
|
79
|
+
}),
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
import * as listLanguageModels from "./listLanguageModels/index";
|
|
5
|
+
export * as listLanguageModels from "./listLanguageModels/index";
|
|
6
|
+
import * as generateContent from "./generateContent/index";
|
|
7
|
+
export * as generateContent from "./generateContent/index";
|
|
8
|
+
|
|
9
|
+
export const actions = {
|
|
10
|
+
"listLanguageModels": listLanguageModels.listLanguageModels,
|
|
11
|
+
"generateContent": generateContent.generateContent,
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
import * as input from "./input";
|
|
5
|
+
export * as input from "./input";
|
|
6
|
+
import * as output from "./output";
|
|
7
|
+
export * as output from "./output";
|
|
8
|
+
|
|
9
|
+
export const listLanguageModels = {
|
|
10
|
+
"input": input.input,
|
|
11
|
+
"output": output.output,
|
|
12
|
+
"billable": false,
|
|
13
|
+
"cacheable": false,
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
|
|
5
|
+
import { z } from "@botpress/sdk";
|
|
6
|
+
export const output = {
|
|
7
|
+
schema: z.object({
|
|
8
|
+
models: z.array(
|
|
9
|
+
z.intersection(
|
|
10
|
+
z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
description: z.string(),
|
|
14
|
+
tags: z.array(
|
|
15
|
+
z.enum([
|
|
16
|
+
"recommended",
|
|
17
|
+
"deprecated",
|
|
18
|
+
"general-purpose",
|
|
19
|
+
"low-cost",
|
|
20
|
+
"vision",
|
|
21
|
+
"coding",
|
|
22
|
+
"agents",
|
|
23
|
+
"function-calling",
|
|
24
|
+
"roleplay",
|
|
25
|
+
"storytelling",
|
|
26
|
+
"reasoning",
|
|
27
|
+
"preview",
|
|
28
|
+
]),
|
|
29
|
+
),
|
|
30
|
+
input: z.object({
|
|
31
|
+
maxTokens: z.number(),
|
|
32
|
+
costPer1MTokens:
|
|
33
|
+
/** Cost per 1 million tokens, in U.S. dollars */ z.number(),
|
|
34
|
+
}),
|
|
35
|
+
output: z.object({
|
|
36
|
+
maxTokens: z.number(),
|
|
37
|
+
costPer1MTokens:
|
|
38
|
+
/** Cost per 1 million tokens, in U.S. dollars */ z.number(),
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
z.ref("modelRef"),
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
|
|
5
|
+
import * as sdk from "@botpress/sdk"
|
|
6
|
+
|
|
7
|
+
import * as actions from "./actions/index"
|
|
8
|
+
import * as channels from "./channels/index"
|
|
9
|
+
import * as events from "./events/index"
|
|
10
|
+
import * as entities from "./entities/index"
|
|
11
|
+
export * as actions from "./actions/index"
|
|
12
|
+
export * as channels from "./channels/index"
|
|
13
|
+
export * as events from "./events/index"
|
|
14
|
+
export * as entities from "./entities/index"
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: "llm",
|
|
18
|
+
version: "8.0.0",
|
|
19
|
+
actions: actions.actions,
|
|
20
|
+
channels: channels.channels,
|
|
21
|
+
events: events.events,
|
|
22
|
+
entities: entities.entities,
|
|
23
|
+
} satisfies sdk.InterfacePackage["definition"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
// This file is generated. Do not edit it manually.
|
|
4
|
+
|
|
5
|
+
import * as sdk from "@botpress/sdk"
|
|
6
|
+
|
|
7
|
+
import definition from "./definition"
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
type: "interface",
|
|
11
|
+
id: "b759e577-2ce7-451a-abff-68085b224985",
|
|
12
|
+
uri: undefined,
|
|
13
|
+
name: "llm",
|
|
14
|
+
version: "8.0.0",
|
|
15
|
+
definition,
|
|
16
|
+
} satisfies sdk.InterfacePackage
|
package/dist/index.cjs
CHANGED
|
@@ -676,9 +676,12 @@ var getActionFromError = (error) => {
|
|
|
676
676
|
return "abort";
|
|
677
677
|
}
|
|
678
678
|
const subtype = error.metadata?.subtype;
|
|
679
|
-
if (
|
|
679
|
+
if (subtype === "UPSTREAM_PROVIDER_FAILED") {
|
|
680
680
|
return "fallback";
|
|
681
681
|
}
|
|
682
|
+
if (error.type === "Internal") {
|
|
683
|
+
return "retry";
|
|
684
|
+
}
|
|
682
685
|
return "abort";
|
|
683
686
|
};
|
|
684
687
|
var isNotFoundError = (error) => isBotpressError(error) && error.type === "ResourceNotFound";
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/options.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/jitter/full/full.jitter.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/jitter/no/no.jitter.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/jitter/jitter.factory.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/delay/delay.base.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/delay/skip-first/skip-first.delay.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/delay/always/always.delay.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/delay/delay.factory.ts", "../../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/src/backoff.ts", "../src/index.ts", "../src/client.ts", "../../../node_modules/.pnpm/nanoevents@9.1.0/node_modules/nanoevents/index.js", "../src/bp-client.ts", "../src/errors.ts", "../src/interceptors.ts", "../src/models.ts"],
|
|
4
|
-
"sourcesContent": [null, null, null, null, null, null, null, null, null, "export { Events, BotpressClientLike } from './types'\nexport * from './client'\nexport { ModelPreferences, ModelProvider, RemoteModelProvider, Model } from './models'\nexport { type GenerateContentInput, type GenerateContentOutput } from './schemas.gen'\n", "import { backOff } from 'exponential-backoff'\nimport { createNanoEvents, Unsubscribe } from 'nanoevents'\n\nimport { ExtendedClient, getExtendedClient } from './bp-client'\nimport { getActionFromError } from './errors'\nimport { InterceptorManager } from './interceptors'\nimport {\n DOWNTIME_THRESHOLD_MINUTES,\n getBestModels,\n getFastModels,\n Model,\n ModelPreferences,\n ModelProvider,\n ModelRef,\n pickModel,\n RemoteModelProvider,\n} from './models'\nimport { GenerateContentOutput } from './schemas.gen'\nimport { CognitiveProps, Events, InputProps, Request, Response } from './types'\n\nexport class Cognitive {\n public ['$$IS_COGNITIVE'] = true\n\n public static isCognitiveClient(obj: any): obj is Cognitive {\n return obj?.$$IS_COGNITIVE === true\n }\n\n public interceptors = {\n request: new InterceptorManager<Request>(),\n response: new InterceptorManager<Response>(),\n }\n\n private _client: ExtendedClient\n private _preferences: ModelPreferences | null = null\n private _provider: ModelProvider\n private _events = createNanoEvents<Events>()\n private _downtimes: ModelPreferences['downtimes'] = []\n private _models: Model[] = []\n\n public constructor(props: CognitiveProps) {\n this._client = getExtendedClient(props.client)\n this._provider = props.provider ?? new RemoteModelProvider(props.client)\n }\n\n public get client(): ExtendedClient {\n return this._client\n }\n\n public on<K extends keyof Events>(this: this, event: K, cb: Events[K]): Unsubscribe {\n return this._events.on(event, cb)\n }\n\n public async fetchInstalledModels(): Promise<Model[]> {\n if (!this._models.length) {\n this._models = await this._provider.fetchInstalledModels()\n }\n\n return this._models\n }\n\n public async fetchPreferences(): Promise<ModelPreferences> {\n if (this._preferences) {\n return this._preferences\n }\n\n this._preferences = await this._provider.fetchModelPreferences()\n\n if (this._preferences) {\n return this._preferences\n }\n\n const models = await this.fetchInstalledModels()\n\n this._preferences = {\n best: getBestModels(models).map((m) => m.ref),\n fast: getFastModels(models).map((m) => m.ref),\n downtimes: [],\n }\n\n await this._provider.saveModelPreferences(this._preferences)\n\n return this._preferences\n }\n\n public async setPreferences(preferences: ModelPreferences, save: boolean = false): Promise<void> {\n this._preferences = preferences\n\n if (save) {\n await this._provider.saveModelPreferences(preferences)\n }\n }\n\n private _cleanupOldDowntimes(): void {\n const now = Date.now()\n const thresholdMs = 1000 * 60 * DOWNTIME_THRESHOLD_MINUTES\n\n this._preferences!.downtimes = this._preferences!.downtimes.filter((downtime) => {\n const downtimeStart = new Date(downtime.startedAt).getTime()\n return now - downtimeStart <= thresholdMs\n })\n }\n\n private async _selectModel(ref: string): Promise<{ integration: string; model: string }> {\n const parseRef = (ref: string) => {\n const parts = ref.split(':')\n return { integration: parts[0]!, model: parts.slice(1).join(':') }\n }\n\n const preferences = await this.fetchPreferences()\n\n preferences.best ??= []\n preferences.fast ??= []\n preferences.downtimes ??= []\n\n const downtimes = [...preferences.downtimes, ...(this._downtimes ?? [])]\n\n if (ref === 'best') {\n return parseRef(pickModel(preferences.best, downtimes))\n }\n\n if (ref === 'fast') {\n return parseRef(pickModel(preferences.fast, downtimes))\n }\n\n return parseRef(pickModel([ref as ModelRef, ...preferences.best, ...preferences.fast], downtimes))\n }\n\n public async getModelDetails(model: string) {\n await this.fetchInstalledModels()\n const { integration, model: modelName } = await this._selectModel(model)\n const def = this._models.find((m) => m.integration === integration && (m.name === modelName || m.id === modelName))\n if (!def) {\n console.info('Models:', this._models)\n throw new Error(`Model ${modelName} not found`)\n }\n\n return def\n }\n\n public async generateContent(input: InputProps): Promise<Response> {\n const start = Date.now()\n\n const signal = input.signal ?? AbortSignal.timeout(30_000)\n\n const client = this._client.abortable(signal)\n\n let props: Request = { input }\n let integration: string\n let model: string\n\n const { output, meta } = await backOff<{\n output: GenerateContentOutput\n meta: any\n }>(\n async () => {\n const selection = await this._selectModel(input.model ?? 'best')\n\n integration = selection.integration\n model = selection.model\n\n props = await this.interceptors.request.run({ input }, signal)\n\n return client.callAction({\n type: `${integration}:generateContent`,\n input: {\n ...props.input,\n model: { id: model },\n },\n }) as Promise<{ output: GenerateContentOutput; meta: any }>\n },\n {\n retry: async (err, _attempt) => {\n if (signal?.aborted) {\n // We don't want to retry if the request was aborted\n this._events.emit('aborted', props, err)\n return false\n }\n\n if (_attempt > 3) {\n // We don't want to retry more than 3 times\n this._events.emit('error', props, err)\n return false\n }\n\n const action = getActionFromError(err)\n\n if (action === 'abort') {\n this._events.emit('error', props, err)\n return false\n }\n\n if (action === 'fallback') {\n // We don't want to retry if the request was already retried with a fallback model\n this._downtimes.push({\n ref: `${integration!}:${model!}`,\n startedAt: new Date().toISOString(),\n reason: 'Model is down',\n })\n\n this._cleanupOldDowntimes()\n\n await this._provider.saveModelPreferences({\n ...(this._preferences ?? { best: [], downtimes: [], fast: [] }),\n downtimes: [...(this._preferences!.downtimes ?? []), ...(this._downtimes ?? [])],\n })\n\n this._events.emit('fallback', props, err)\n return true\n }\n\n this._events.emit('retry', props, err)\n return true\n },\n }\n )\n\n const response = {\n output,\n meta: {\n cached: meta.cached ?? false,\n model: { integration: integration!, model: model! },\n latency: Date.now() - start,\n cost: { input: output.usage.inputCost, output: output.usage.outputCost },\n tokens: { input: output.usage.inputTokens, output: output.usage.outputTokens },\n },\n } satisfies Response\n\n this._events.emit('response', props, response)\n\n return this.interceptors.response.run(response, signal)\n }\n}\n", "export let createNanoEvents = () => ({\n emit(event, ...args) {\n for (\n let callbacks = this.events[event] || [],\n i = 0,\n length = callbacks.length;\n i < length;\n i++\n ) {\n callbacks[i](...args)\n }\n },\n events: {},\n on(event, cb) {\n ;(this.events[event] ||= []).push(cb)\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n})\n", "import { type Client } from '@botpress/client'\nimport { type AxiosInstance } from 'axios'\nimport { BotpressClientLike } from './types'\n\n/** @internal */\nexport type ExtendedClient = Client & {\n botId: string\n axios: AxiosInstance\n clone: () => ExtendedClient\n abortable: (signal: AbortSignal) => ExtendedClient\n}\n\ntype InternalClientType = BotpressClientLike & {\n _client?: InternalClientType\n config: {\n headers: Record<string, string>\n }\n}\n\nexport const getExtendedClient = (_client: unknown): ExtendedClient => {\n const client = _client as InternalClientType\n\n if (!client || client === null || typeof client !== 'object') {\n throw new Error('Client must be a valid instance of a Botpress client (@botpress/client)')\n }\n\n if (typeof client._client === 'object' && !!client._client) {\n try {\n return getExtendedClient((client as any)._client)\n } catch {}\n }\n\n if (\n typeof client.constructor !== 'function' ||\n typeof client.callAction !== 'function' ||\n !client.config ||\n typeof client.config !== 'object' ||\n !client.config.headers\n ) {\n throw new Error('Client must be a valid instance of a Botpress client (@botpress/client)')\n }\n\n const botId = client.config.headers['x-bot-id'] as string\n\n if (!botId?.length) {\n throw new Error('Client must be instanciated with Bot ID')\n }\n\n const clone = () => {\n const c = client as any\n if (c.clone && typeof c.clone === 'function') {\n return getExtendedClient(c.clone())\n }\n return getExtendedClient(new c.constructor(c.config))\n }\n\n return {\n ...client,\n botId,\n axios: (client as any).axiosInstance as AxiosInstance,\n clone,\n abortable: (signal: AbortSignal) => {\n const abortable = clone()\n const instance = abortable.axios\n instance.defaults.signal = signal\n return abortable\n },\n } as ExtendedClient\n}\n", "import { type ErrorType } from '@botpress/client'\n\nexport type BotpressError = {\n isApiError: boolean\n code: number\n description: string\n type: ErrorType\n subtype?: string\n error?: unknown\n metadata?: unknown\n message?: string\n id: string\n}\n\ntype Action = 'fallback' | 'retry' | 'abort'\n\nexport const getActionFromError = (error: any): Action => {\n if (!isBotpressError(error)) {\n return 'retry'\n }\n\n if (error.type === 'InvalidDataFormat') {\n if (error.message?.includes('data/model/id')) {\n // Invalid Model ID, so we want to try another model\n return 'fallback'\n }\n\n // Usually means the request was malformed\n return 'abort'\n }\n\n const subtype = (error.metadata as any)?.subtype\n if (error.type === 'Internal' || subtype === 'UPSTREAM_PROVIDER_FAILED') {\n // The model is degraded, so we want to try another model\n return 'fallback'\n }\n\n return 'abort'\n}\n\nexport const isNotFoundError = (error: any): boolean => isBotpressError(error) && error.type === 'ResourceNotFound'\n\nexport const isForbiddenOrUnauthorizedError = (error: any): boolean =>\n isBotpressError(error) && (error.type === 'Forbidden' || error.type === 'Unauthorized')\n\nexport const isBotpressError = (error: any): error is BotpressError =>\n typeof error === 'object' &&\n error !== null &&\n 'isApiError' in error &&\n 'code' in error &&\n 'type' in error &&\n 'id' in error\n", "export type Callback<T> = (error: any | null, value: T) => void\nexport type Interceptor<T> = (error: any | null, value: T, next: Callback<T>, done: Callback<T>) => Promise<void> | void\n\nexport class InterceptorManager<T> {\n private _interceptors: Interceptor<T>[] = []\n\n public use(interceptor: Interceptor<T>) {\n this._interceptors.push(interceptor)\n return () => this.remove(interceptor)\n }\n\n public remove(interceptor: Interceptor<T>) {\n this._interceptors = this._interceptors.filter((i) => i !== interceptor)\n }\n\n public async run(value: T, signal: AbortSignal): Promise<T> {\n let error: any | null = null\n let result: T = value\n let done = false\n\n for (const interceptor of this._interceptors) {\n if (done) {\n break\n }\n\n if (signal.aborted) {\n throw signal.reason\n }\n\n await new Promise<void>((resolve) => {\n void interceptor(\n error,\n result,\n (err, val) => {\n error = err\n result = val\n resolve()\n },\n (err, val) => {\n error = err\n result = val\n done = true\n resolve()\n }\n )\n })\n }\n\n if (error) {\n throw error\n }\n\n return result\n }\n}\n", "import { ExtendedClient, getExtendedClient } from './bp-client'\nimport { isForbiddenOrUnauthorizedError, isNotFoundError } from './errors'\nimport { Model as RawModel } from './schemas.gen'\nimport { BotpressClientLike } from './types'\n\nexport const DOWNTIME_THRESHOLD_MINUTES = 5\nconst PREFERENCES_FILE_SUFFIX = 'models.config.json'\n\nexport const DEFAULT_INTEGRATIONS = ['google-ai', 'anthropic', 'openai', 'cerebras', 'fireworks-ai', 'groq']\n\n// Biases for vendors and models\nconst VendorPreferences = ['google-ai', 'anthropic', 'openai']\nconst BestModelPreferences = ['4o', '3-5-sonnet', 'gemini-1.5-pro']\nconst FastModelPreferences = ['gemini-1.5-flash', '4o-mini', 'flash', 'haiku']\n\nconst InputPricePenalty = 3 // $3 per 1M tokens\nconst OutputPricePenalty = 10 // $10 per 1M tokens\nconst LowTokensPenalty = 128_000 // 128k tokens\n\nexport type Model = RawModel & {\n ref: ModelRef\n integration: string\n}\n\nexport type ModelRef = `${string}:${string}`\n\nexport type ModelPreferences = {\n best: ModelRef[]\n fast: ModelRef[]\n downtimes: Array<{ ref: ModelRef; startedAt: string; reason: string }>\n}\n\nconst isRecommended = (model: Model) => model.tags.includes('recommended')\nconst isDeprecated = (model: Model) => model.tags.includes('deprecated')\nconst isLowCost = (model: Model) => model.tags.includes('low-cost')\nconst hasVisionSupport = (model: Model) => model.tags.includes('vision')\nconst isGeneralPurpose = (model: Model) => model.tags.includes('general-purpose')\n\nconst scoreModel = (model: Model, type: 'best' | 'fast', boosts: Record<ModelRef, number> = {}) => {\n let score: number = 0\n\n const scores: Array<[string, boolean, number]> = [\n ['input price penalty', model.input.costPer1MTokens > InputPricePenalty, -1],\n ['output price penalty', model.output.costPer1MTokens > OutputPricePenalty, -1],\n ['low tokens penalty', (model.input.maxTokens ?? 0 + model.output.maxTokens ?? 0) < LowTokensPenalty, -1],\n ['recommended', isRecommended(model), 2],\n ['deprecated', isDeprecated(model), -2],\n ['vision support', hasVisionSupport(model), 1],\n ['general purpose', isGeneralPurpose(model), 1],\n ['vendor preference', VendorPreferences.includes(model.integration), 1],\n ['best model preference', type === 'best' && BestModelPreferences.some((x) => model.id.includes(x)), 1],\n ['fast model preference penalty', type === 'best' && FastModelPreferences.some((x) => model.id.includes(x)), -2],\n ['fast model preference', type === 'fast' && FastModelPreferences.some((x) => model.id.includes(x)), 2],\n ['low cost', type === 'fast' && isLowCost(model), 1],\n ]\n\n for (const rule in boosts) {\n if (model.ref.includes(rule)) {\n scores.push([`boost (${rule})`, true, Number(boosts[rule as ModelRef]) ?? 0] as const)\n }\n }\n\n for (const [, condition, value] of scores) {\n if (condition) {\n score += value\n }\n }\n\n return score\n}\n\nexport const getBestModels = (models: Model[], boosts: Record<ModelRef, number> = {}) =>\n models.sort((a, b) => scoreModel(b, 'best', boosts) - scoreModel(a, 'best', boosts))\n\nexport const getFastModels = (models: Model[], boosts: Record<ModelRef, number> = {}) =>\n models.sort((a, b) => scoreModel(b, 'fast', boosts) - scoreModel(a, 'fast', boosts))\n\nexport const pickModel = (models: ModelRef[], downtimes: ModelPreferences['downtimes'] = []) => {\n const copy = [...models]\n const elasped = (date: string) => new Date().getTime() - new Date(date).getTime()\n const DOWNTIME_THRESHOLD = 1000 * 60 * DOWNTIME_THRESHOLD_MINUTES\n\n if (!copy.length) {\n throw new Error('At least one model is required')\n }\n\n while (copy.length) {\n const ref = copy.shift() as ModelRef\n const downtime = downtimes.find((o) => o.ref === ref && elasped(o.startedAt) < DOWNTIME_THRESHOLD)\n if (downtime) {\n continue\n } else {\n return ref\n }\n }\n\n throw new Error(`All models are down: ${models.join(', ')}`)\n}\n\nexport abstract class ModelProvider {\n public abstract fetchInstalledModels(): Promise<Model[]>\n public abstract fetchModelPreferences(): Promise<ModelPreferences | null>\n public abstract saveModelPreferences(preferences: ModelPreferences): Promise<void>\n public abstract deleteModelPreferences(): Promise<void>\n}\n\nexport class RemoteModelProvider extends ModelProvider {\n private _client: ExtendedClient\n\n public constructor(client: BotpressClientLike) {\n super()\n this._client = getExtendedClient(client)\n }\n\n private async _fetchInstalledIntegrationNames() {\n try {\n const { bot } = await this._client.getBot({ id: this._client.botId })\n const integrations = Object.values(bot.integrations).filter((x) => x.status === 'registered')\n return integrations.map((x) => x.name)\n } catch (err) {\n if (isForbiddenOrUnauthorizedError(err)) {\n // This happens when the bot (with a BAK token) tries to access the .getBot endpoint\n return DEFAULT_INTEGRATIONS\n }\n\n throw err\n }\n }\n\n public async fetchInstalledModels() {\n const integrationNames = await this._fetchInstalledIntegrationNames()\n const models: Model[] = []\n\n await Promise.allSettled(\n integrationNames.map(async (integration) => {\n const { output } = await this._client.callAction({\n type: `${integration}:listLanguageModels`,\n input: {},\n })\n\n if (!output?.models?.length) {\n return\n }\n\n for (const model of output.models as RawModel[]) {\n if (model.name && model.id && model.input && model.tags) {\n models.push({\n ref: `${integration}:${model.id}`,\n integration,\n id: model.id,\n name: model.name,\n description: model.description,\n input: model.input,\n output: model.output,\n tags: model.tags,\n })\n }\n }\n })\n )\n\n return models\n }\n\n public async fetchModelPreferences(): Promise<ModelPreferences | null> {\n try {\n const { file } = await this._client.getFile({ id: this._preferenceFileKey })\n\n if (globalThis.fetch !== undefined) {\n const response = await fetch(file.url)\n return (await response.json()) as ModelPreferences\n } else {\n const { data } = await this._client.axios.get(file.url, {\n // we piggy-back axios to avoid adding a new dependency\n // unset all headers to avoid S3 pre-signed signature mismatch\n headers: Object.keys(this._client.config.headers).reduce(\n (acc, key) => {\n acc[key] = undefined\n return acc\n },\n {} as Record<string, undefined>\n ),\n })\n return data as ModelPreferences\n }\n } catch (err) {\n if (isNotFoundError(err)) {\n return null\n }\n\n throw err\n }\n }\n\n public async saveModelPreferences(preferences: ModelPreferences) {\n await this._client.uploadFile({\n key: this._preferenceFileKey,\n content: JSON.stringify(preferences, null, 2),\n index: false,\n tags: {\n system: 'true',\n purpose: 'config',\n },\n })\n }\n\n public async deleteModelPreferences() {\n await this._client.deleteFile({ id: this._preferenceFileKey }).catch(() => {})\n }\n\n private get _preferenceFileKey() {\n return `bot->${this._client.botId}->${PREFERENCES_FILE_SUFFIX}`\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,QAAM,iBAAkC;MACtC,mBAAmB;MACnB,QAAQ;MACR,UAAU;MACV,eAAe;MACf,OAAO,WAAA;AAAM,eAAA;MAAA;MACb,eAAe;MACf,cAAc;;AAGhB,aAAgB,oBAAoB,SAAuB;AACzD,UAAM,YAAS,SAAA,SAAA,CAAA,GAAyB,cAAc,GAAK,OAAO;AAElE,UAAI,UAAU,gBAAgB,GAAG;AAC/B,kBAAU,gBAAgB;;AAG5B,aAAO;IACT;AARA,YAAA,sBAAA;;;;;;;;;ACxBA,aAAgB,WAAW,O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SAAS,OAAO,GAAG;AACrC,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAEA,UAAM,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,QACJ,QAAQ,KAAK,UAAU;AAAA,QACvB,OAAO,EAAE,aAA2B,MAAc;AAAA,QAClD,SAAS,KAAK,IAAI,IAAI;AAAA,QACtB,MAAM,EAAE,OAAO,OAAO,MAAM,WAAW,QAAQ,OAAO,MAAM,WAAW;AAAA,QACvE,QAAQ,EAAE,OAAO,OAAO,MAAM,aAAa,QAAQ,OAAO,MAAM,aAAa;AAAA,MAC/E;AAAA,IACF;AAEA,SAAK,QAAQ,KAAK,YAAY,OAAO,QAAQ;AAE7C,WAAO,KAAK,aAAa,SAAS,IAAI,UAAU,MAAM;AAAA,EACxD;AACF;",
|
|
4
|
+
"sourcesContent": [null, null, null, null, null, null, null, null, null, "export { Events, BotpressClientLike } from './types'\nexport * from './client'\nexport { ModelPreferences, ModelProvider, RemoteModelProvider, Model } from './models'\nexport { type GenerateContentInput, type GenerateContentOutput } from './schemas.gen'\n", "import { backOff } from 'exponential-backoff'\nimport { createNanoEvents, Unsubscribe } from 'nanoevents'\n\nimport { ExtendedClient, getExtendedClient } from './bp-client'\nimport { getActionFromError } from './errors'\nimport { InterceptorManager } from './interceptors'\nimport {\n DOWNTIME_THRESHOLD_MINUTES,\n getBestModels,\n getFastModels,\n Model,\n ModelPreferences,\n ModelProvider,\n ModelRef,\n pickModel,\n RemoteModelProvider,\n} from './models'\nimport { GenerateContentOutput } from './schemas.gen'\nimport { CognitiveProps, Events, InputProps, Request, Response } from './types'\n\nexport class Cognitive {\n public ['$$IS_COGNITIVE'] = true\n\n public static isCognitiveClient(obj: any): obj is Cognitive {\n return obj?.$$IS_COGNITIVE === true\n }\n\n public interceptors = {\n request: new InterceptorManager<Request>(),\n response: new InterceptorManager<Response>(),\n }\n\n private _client: ExtendedClient\n private _preferences: ModelPreferences | null = null\n private _provider: ModelProvider\n private _events = createNanoEvents<Events>()\n private _downtimes: ModelPreferences['downtimes'] = []\n private _models: Model[] = []\n\n public constructor(props: CognitiveProps) {\n this._client = getExtendedClient(props.client)\n this._provider = props.provider ?? new RemoteModelProvider(props.client)\n }\n\n public get client(): ExtendedClient {\n return this._client\n }\n\n public on<K extends keyof Events>(this: this, event: K, cb: Events[K]): Unsubscribe {\n return this._events.on(event, cb)\n }\n\n public async fetchInstalledModels(): Promise<Model[]> {\n if (!this._models.length) {\n this._models = await this._provider.fetchInstalledModels()\n }\n\n return this._models\n }\n\n public async fetchPreferences(): Promise<ModelPreferences> {\n if (this._preferences) {\n return this._preferences\n }\n\n this._preferences = await this._provider.fetchModelPreferences()\n\n if (this._preferences) {\n return this._preferences\n }\n\n const models = await this.fetchInstalledModels()\n\n this._preferences = {\n best: getBestModels(models).map((m) => m.ref),\n fast: getFastModels(models).map((m) => m.ref),\n downtimes: [],\n }\n\n await this._provider.saveModelPreferences(this._preferences)\n\n return this._preferences\n }\n\n public async setPreferences(preferences: ModelPreferences, save: boolean = false): Promise<void> {\n this._preferences = preferences\n\n if (save) {\n await this._provider.saveModelPreferences(preferences)\n }\n }\n\n private _cleanupOldDowntimes(): void {\n const now = Date.now()\n const thresholdMs = 1000 * 60 * DOWNTIME_THRESHOLD_MINUTES\n\n this._preferences!.downtimes = this._preferences!.downtimes.filter((downtime) => {\n const downtimeStart = new Date(downtime.startedAt).getTime()\n return now - downtimeStart <= thresholdMs\n })\n }\n\n private async _selectModel(ref: string): Promise<{ integration: string; model: string }> {\n const parseRef = (ref: string) => {\n const parts = ref.split(':')\n return { integration: parts[0]!, model: parts.slice(1).join(':') }\n }\n\n const preferences = await this.fetchPreferences()\n\n preferences.best ??= []\n preferences.fast ??= []\n preferences.downtimes ??= []\n\n const downtimes = [...preferences.downtimes, ...(this._downtimes ?? [])]\n\n if (ref === 'best') {\n return parseRef(pickModel(preferences.best, downtimes))\n }\n\n if (ref === 'fast') {\n return parseRef(pickModel(preferences.fast, downtimes))\n }\n\n return parseRef(pickModel([ref as ModelRef, ...preferences.best, ...preferences.fast], downtimes))\n }\n\n public async getModelDetails(model: string) {\n await this.fetchInstalledModels()\n const { integration, model: modelName } = await this._selectModel(model)\n const def = this._models.find((m) => m.integration === integration && (m.name === modelName || m.id === modelName))\n if (!def) {\n console.info('Models:', this._models)\n throw new Error(`Model ${modelName} not found`)\n }\n\n return def\n }\n\n public async generateContent(input: InputProps): Promise<Response> {\n const start = Date.now()\n\n const signal = input.signal ?? AbortSignal.timeout(30_000)\n\n const client = this._client.abortable(signal)\n\n let props: Request = { input }\n let integration: string\n let model: string\n\n const { output, meta } = await backOff<{\n output: GenerateContentOutput\n meta: any\n }>(\n async () => {\n const selection = await this._selectModel(input.model ?? 'best')\n\n integration = selection.integration\n model = selection.model\n\n props = await this.interceptors.request.run({ input }, signal)\n\n return client.callAction({\n type: `${integration}:generateContent`,\n input: {\n ...props.input,\n model: { id: model },\n },\n }) as Promise<{ output: GenerateContentOutput; meta: any }>\n },\n {\n retry: async (err, _attempt) => {\n if (signal?.aborted) {\n // We don't want to retry if the request was aborted\n this._events.emit('aborted', props, err)\n return false\n }\n\n if (_attempt > 3) {\n // We don't want to retry more than 3 times\n this._events.emit('error', props, err)\n return false\n }\n\n const action = getActionFromError(err)\n\n if (action === 'abort') {\n this._events.emit('error', props, err)\n return false\n }\n\n if (action === 'fallback') {\n // We don't want to retry if the request was already retried with a fallback model\n this._downtimes.push({\n ref: `${integration!}:${model!}`,\n startedAt: new Date().toISOString(),\n reason: 'Model is down',\n })\n\n this._cleanupOldDowntimes()\n\n await this._provider.saveModelPreferences({\n ...(this._preferences ?? { best: [], downtimes: [], fast: [] }),\n downtimes: [...(this._preferences!.downtimes ?? []), ...(this._downtimes ?? [])],\n })\n\n this._events.emit('fallback', props, err)\n return true\n }\n\n this._events.emit('retry', props, err)\n return true\n },\n }\n )\n\n const response = {\n output,\n meta: {\n cached: meta.cached ?? false,\n model: { integration: integration!, model: model! },\n latency: Date.now() - start,\n cost: { input: output.usage.inputCost, output: output.usage.outputCost },\n tokens: { input: output.usage.inputTokens, output: output.usage.outputTokens },\n },\n } satisfies Response\n\n this._events.emit('response', props, response)\n\n return this.interceptors.response.run(response, signal)\n }\n}\n", "export let createNanoEvents = () => ({\n emit(event, ...args) {\n for (\n let callbacks = this.events[event] || [],\n i = 0,\n length = callbacks.length;\n i < length;\n i++\n ) {\n callbacks[i](...args)\n }\n },\n events: {},\n on(event, cb) {\n ;(this.events[event] ||= []).push(cb)\n return () => {\n this.events[event] = this.events[event]?.filter(i => cb !== i)\n }\n }\n})\n", "import { type Client } from '@botpress/client'\nimport { type AxiosInstance } from 'axios'\nimport { BotpressClientLike } from './types'\n\n/** @internal */\nexport type ExtendedClient = Client & {\n botId: string\n axios: AxiosInstance\n clone: () => ExtendedClient\n abortable: (signal: AbortSignal) => ExtendedClient\n}\n\ntype InternalClientType = BotpressClientLike & {\n _client?: InternalClientType\n config: {\n headers: Record<string, string>\n }\n}\n\nexport const getExtendedClient = (_client: unknown): ExtendedClient => {\n const client = _client as InternalClientType\n\n if (!client || client === null || typeof client !== 'object') {\n throw new Error('Client must be a valid instance of a Botpress client (@botpress/client)')\n }\n\n if (typeof client._client === 'object' && !!client._client) {\n try {\n return getExtendedClient((client as any)._client)\n } catch {}\n }\n\n if (\n typeof client.constructor !== 'function' ||\n typeof client.callAction !== 'function' ||\n !client.config ||\n typeof client.config !== 'object' ||\n !client.config.headers\n ) {\n throw new Error('Client must be a valid instance of a Botpress client (@botpress/client)')\n }\n\n const botId = client.config.headers['x-bot-id'] as string\n\n if (!botId?.length) {\n throw new Error('Client must be instanciated with Bot ID')\n }\n\n const clone = () => {\n const c = client as any\n if (c.clone && typeof c.clone === 'function') {\n return getExtendedClient(c.clone())\n }\n return getExtendedClient(new c.constructor(c.config))\n }\n\n return {\n ...client,\n botId,\n axios: (client as any).axiosInstance as AxiosInstance,\n clone,\n abortable: (signal: AbortSignal) => {\n const abortable = clone()\n const instance = abortable.axios\n instance.defaults.signal = signal\n return abortable\n },\n } as ExtendedClient\n}\n", "import { type ErrorType } from '@botpress/client'\n\nexport type BotpressError = {\n isApiError: boolean\n code: number\n description: string\n type: ErrorType\n subtype?: string\n error?: unknown\n metadata?: unknown\n message?: string\n id: string\n}\n\ntype Action = 'fallback' | 'retry' | 'abort'\n\nexport const getActionFromError = (error: any): Action => {\n if (!isBotpressError(error)) {\n return 'retry'\n }\n\n if (error.type === 'InvalidDataFormat') {\n if (error.message?.includes('data/model/id')) {\n // Invalid Model ID, so we want to try another model\n return 'fallback'\n }\n\n // Usually means the request was malformed\n return 'abort'\n }\n\n const subtype = (error.metadata as any)?.subtype\n if (subtype === 'UPSTREAM_PROVIDER_FAILED') {\n // The model is degraded, so we want to try another model\n return 'fallback'\n }\n\n if (error.type === 'Internal') {\n // This is an internal error, probably a lambda timeout\n return 'retry'\n }\n\n return 'abort'\n}\n\nexport const isNotFoundError = (error: any): boolean => isBotpressError(error) && error.type === 'ResourceNotFound'\n\nexport const isForbiddenOrUnauthorizedError = (error: any): boolean =>\n isBotpressError(error) && (error.type === 'Forbidden' || error.type === 'Unauthorized')\n\nexport const isBotpressError = (error: any): error is BotpressError =>\n typeof error === 'object' &&\n error !== null &&\n 'isApiError' in error &&\n 'code' in error &&\n 'type' in error &&\n 'id' in error\n", "export type Callback<T> = (error: any | null, value: T) => void\nexport type Interceptor<T> = (error: any | null, value: T, next: Callback<T>, done: Callback<T>) => Promise<void> | void\n\nexport class InterceptorManager<T> {\n private _interceptors: Interceptor<T>[] = []\n\n public use(interceptor: Interceptor<T>) {\n this._interceptors.push(interceptor)\n return () => this.remove(interceptor)\n }\n\n public remove(interceptor: Interceptor<T>) {\n this._interceptors = this._interceptors.filter((i) => i !== interceptor)\n }\n\n public async run(value: T, signal: AbortSignal): Promise<T> {\n let error: any | null = null\n let result: T = value\n let done = false\n\n for (const interceptor of this._interceptors) {\n if (done) {\n break\n }\n\n if (signal.aborted) {\n throw signal.reason\n }\n\n await new Promise<void>((resolve) => {\n void interceptor(\n error,\n result,\n (err, val) => {\n error = err\n result = val\n resolve()\n },\n (err, val) => {\n error = err\n result = val\n done = true\n resolve()\n }\n )\n })\n }\n\n if (error) {\n throw error\n }\n\n return result\n }\n}\n", "import { ExtendedClient, getExtendedClient } from './bp-client'\nimport { isForbiddenOrUnauthorizedError, isNotFoundError } from './errors'\nimport { Model as RawModel } from './schemas.gen'\nimport { BotpressClientLike } from './types'\n\nexport const DOWNTIME_THRESHOLD_MINUTES = 5\nconst PREFERENCES_FILE_SUFFIX = 'models.config.json'\n\nexport const DEFAULT_INTEGRATIONS = ['google-ai', 'anthropic', 'openai', 'cerebras', 'fireworks-ai', 'groq']\n\n// Biases for vendors and models\nconst VendorPreferences = ['google-ai', 'anthropic', 'openai']\nconst BestModelPreferences = ['4o', '3-5-sonnet', 'gemini-1.5-pro']\nconst FastModelPreferences = ['gemini-1.5-flash', '4o-mini', 'flash', 'haiku']\n\nconst InputPricePenalty = 3 // $3 per 1M tokens\nconst OutputPricePenalty = 10 // $10 per 1M tokens\nconst LowTokensPenalty = 128_000 // 128k tokens\n\nexport type Model = RawModel & {\n ref: ModelRef\n integration: string\n}\n\nexport type ModelRef = `${string}:${string}`\n\nexport type ModelPreferences = {\n best: ModelRef[]\n fast: ModelRef[]\n downtimes: Array<{ ref: ModelRef; startedAt: string; reason: string }>\n}\n\nconst isRecommended = (model: Model) => model.tags.includes('recommended')\nconst isDeprecated = (model: Model) => model.tags.includes('deprecated')\nconst isLowCost = (model: Model) => model.tags.includes('low-cost')\nconst hasVisionSupport = (model: Model) => model.tags.includes('vision')\nconst isGeneralPurpose = (model: Model) => model.tags.includes('general-purpose')\n\nconst scoreModel = (model: Model, type: 'best' | 'fast', boosts: Record<ModelRef, number> = {}) => {\n let score: number = 0\n\n const scores: Array<[string, boolean, number]> = [\n ['input price penalty', model.input.costPer1MTokens > InputPricePenalty, -1],\n ['output price penalty', model.output.costPer1MTokens > OutputPricePenalty, -1],\n ['low tokens penalty', (model.input.maxTokens ?? 0 + model.output.maxTokens ?? 0) < LowTokensPenalty, -1],\n ['recommended', isRecommended(model), 2],\n ['deprecated', isDeprecated(model), -2],\n ['vision support', hasVisionSupport(model), 1],\n ['general purpose', isGeneralPurpose(model), 1],\n ['vendor preference', VendorPreferences.includes(model.integration), 1],\n ['best model preference', type === 'best' && BestModelPreferences.some((x) => model.id.includes(x)), 1],\n ['fast model preference penalty', type === 'best' && FastModelPreferences.some((x) => model.id.includes(x)), -2],\n ['fast model preference', type === 'fast' && FastModelPreferences.some((x) => model.id.includes(x)), 2],\n ['low cost', type === 'fast' && isLowCost(model), 1],\n ]\n\n for (const rule in boosts) {\n if (model.ref.includes(rule)) {\n scores.push([`boost (${rule})`, true, Number(boosts[rule as ModelRef]) ?? 0] as const)\n }\n }\n\n for (const [, condition, value] of scores) {\n if (condition) {\n score += value\n }\n }\n\n return score\n}\n\nexport const getBestModels = (models: Model[], boosts: Record<ModelRef, number> = {}) =>\n models.sort((a, b) => scoreModel(b, 'best', boosts) - scoreModel(a, 'best', boosts))\n\nexport const getFastModels = (models: Model[], boosts: Record<ModelRef, number> = {}) =>\n models.sort((a, b) => scoreModel(b, 'fast', boosts) - scoreModel(a, 'fast', boosts))\n\nexport const pickModel = (models: ModelRef[], downtimes: ModelPreferences['downtimes'] = []) => {\n const copy = [...models]\n const elasped = (date: string) => new Date().getTime() - new Date(date).getTime()\n const DOWNTIME_THRESHOLD = 1000 * 60 * DOWNTIME_THRESHOLD_MINUTES\n\n if (!copy.length) {\n throw new Error('At least one model is required')\n }\n\n while (copy.length) {\n const ref = copy.shift() as ModelRef\n const downtime = downtimes.find((o) => o.ref === ref && elasped(o.startedAt) < DOWNTIME_THRESHOLD)\n if (downtime) {\n continue\n } else {\n return ref\n }\n }\n\n throw new Error(`All models are down: ${models.join(', ')}`)\n}\n\nexport abstract class ModelProvider {\n public abstract fetchInstalledModels(): Promise<Model[]>\n public abstract fetchModelPreferences(): Promise<ModelPreferences | null>\n public abstract saveModelPreferences(preferences: ModelPreferences): Promise<void>\n public abstract deleteModelPreferences(): Promise<void>\n}\n\nexport class RemoteModelProvider extends ModelProvider {\n private _client: ExtendedClient\n\n public constructor(client: BotpressClientLike) {\n super()\n this._client = getExtendedClient(client)\n }\n\n private async _fetchInstalledIntegrationNames() {\n try {\n const { bot } = await this._client.getBot({ id: this._client.botId })\n const integrations = Object.values(bot.integrations).filter((x) => x.status === 'registered')\n return integrations.map((x) => x.name)\n } catch (err) {\n if (isForbiddenOrUnauthorizedError(err)) {\n // This happens when the bot (with a BAK token) tries to access the .getBot endpoint\n return DEFAULT_INTEGRATIONS\n }\n\n throw err\n }\n }\n\n public async fetchInstalledModels() {\n const integrationNames = await this._fetchInstalledIntegrationNames()\n const models: Model[] = []\n\n await Promise.allSettled(\n integrationNames.map(async (integration) => {\n const { output } = await this._client.callAction({\n type: `${integration}:listLanguageModels`,\n input: {},\n })\n\n if (!output?.models?.length) {\n return\n }\n\n for (const model of output.models as RawModel[]) {\n if (model.name && model.id && model.input && model.tags) {\n models.push({\n ref: `${integration}:${model.id}`,\n integration,\n id: model.id,\n name: model.name,\n description: model.description,\n input: model.input,\n output: model.output,\n tags: model.tags,\n })\n }\n }\n })\n )\n\n return models\n }\n\n public async fetchModelPreferences(): Promise<ModelPreferences | null> {\n try {\n const { file } = await this._client.getFile({ id: this._preferenceFileKey })\n\n if (globalThis.fetch !== undefined) {\n const response = await fetch(file.url)\n return (await response.json()) as ModelPreferences\n } else {\n const { data } = await this._client.axios.get(file.url, {\n // we piggy-back axios to avoid adding a new dependency\n // unset all headers to avoid S3 pre-signed signature mismatch\n headers: Object.keys(this._client.config.headers).reduce(\n (acc, key) => {\n acc[key] = undefined\n return acc\n },\n {} as Record<string, undefined>\n ),\n })\n return data as ModelPreferences\n }\n } catch (err) {\n if (isNotFoundError(err)) {\n return null\n }\n\n throw err\n }\n }\n\n public async saveModelPreferences(preferences: ModelPreferences) {\n await this._client.uploadFile({\n key: this._preferenceFileKey,\n content: JSON.stringify(preferences, null, 2),\n index: false,\n tags: {\n system: 'true',\n purpose: 'config',\n },\n })\n }\n\n public async deleteModelPreferences() {\n await this._client.deleteFile({ id: this._preferenceFileKey }).catch(() => {})\n }\n\n private get _preferenceFileKey() {\n return `bot->${this._client.botId}->${PREFERENCES_FILE_SUFFIX}`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,QAAM,iBAAkC;MACtC,mBAAmB;MACnB,QAAQ;MACR,UAAU;MACV,eAAe;MACf,OAAO,WAAA;AAAM,eAAA;MAAA;MACb,eAAe;MACf,cAAc;;AAGhB,aAAgB,oBAAoB,SAAuB;AACzD,UAAM,YAAS,SAAA,SAAA,CAAA,GAAyB,cAAc,GAAK,OAAO;AAElE,UAAI,UAAU,gBAAgB,GAAG;AAC/B,kBAAU,gBAAgB;;AAG5B,aAAO;IACT;AARA,YAAA,sBAAA;;;;;;;;;ACxBA,aAAgB,WAAW,OAAa;AACpC,UAAM,gBAAgB,KAAK,OAAM,IAAK;AACtC,aAAO,KAAK,MAAM,aAAa;IACnC;AAHA,YAAA,aAAA;;;;;;;;;ACAA,aAAgB,SAAS,OAAa;AAClC,aAAO;IACX;AAFA,YAAA,WAAA;;;;;;;;;ACCA,QAAA,gBAAA;AACA,QAAA,cAAA;AAIA,aAAgB,cAAc,SAAwB;AACpD,cAAQ,QAAQ,QAAQ;QACtB,KAAK;AACH,iBAAO,cAAA;QAET,KAAK;QACL;AACE,iBAAO,YAAA;;IAEb;AATA,YAAA,gBAAA;;;;;;;;;ACJA,QAAA,mBAAA;AAEA,QAAA;;MAAA,WAAA;AAEE,iBAAAA,OAAoB,SAAwB;AAAxB,eAAA,UAAA;AADV,eAAA,UAAU;QAC2B;AAExC,QAAAA,OAAA,UAAA,QAAP,WAAA;AAAA,cAAA,QAAA;AACE,iBAAO,IAAI,QAAQ,SAAA,SAAO;AAAI,mBAAA,WAAW,SAAS,MAAK,aAAa;U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