@botpress/zai 2.0.16 → 2.1.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/context.js +131 -0
- package/dist/emitter.js +42 -0
- package/dist/index.d.ts +104 -9
- package/dist/operations/check.js +46 -27
- package/dist/operations/extract.js +63 -46
- package/dist/operations/filter.js +34 -19
- package/dist/operations/label.js +65 -42
- package/dist/operations/rewrite.js +37 -17
- package/dist/operations/summarize.js +32 -13
- package/dist/operations/text.js +28 -8
- package/dist/response.js +82 -0
- package/dist/tokenizer.js +11 -0
- package/e2e/client.ts +43 -29
- package/e2e/data/cache.jsonl +276 -0
- package/package.json +11 -3
- package/src/context.ts +197 -0
- package/src/emitter.ts +49 -0
- package/src/operations/check.ts +99 -49
- package/src/operations/extract.ts +85 -60
- package/src/operations/filter.ts +62 -35
- package/src/operations/label.ts +117 -62
- package/src/operations/rewrite.ts +50 -21
- package/src/operations/summarize.ts +40 -14
- package/src/operations/text.ts +32 -8
- package/src/response.ts +114 -0
- package/src/tokenizer.ts +14 -0
package/e2e/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from '@botpress/client'
|
|
2
|
-
import { Cognitive } from '@botpress/cognitive'
|
|
2
|
+
import { Cognitive, ModelProvider } from '@botpress/cognitive'
|
|
3
3
|
import { diffLines } from 'diff'
|
|
4
4
|
import fs from 'node:fs'
|
|
5
5
|
import path from 'node:path'
|
|
@@ -102,6 +102,47 @@ class CachedClient extends Client {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
const cognitiveProvider: ModelProvider = {
|
|
106
|
+
deleteModelPreferences: async () => {},
|
|
107
|
+
saveModelPreferences: async () => {},
|
|
108
|
+
fetchInstalledModels: async () => [
|
|
109
|
+
{
|
|
110
|
+
ref: 'openai:gpt-4o-2024-11-20',
|
|
111
|
+
integration: 'openai',
|
|
112
|
+
id: 'gpt-4o-2024-11-20',
|
|
113
|
+
name: 'GPT-4o (November 2024)',
|
|
114
|
+
description:
|
|
115
|
+
"GPT-4o (“o” for “omni”) is OpenAI's most advanced model. It is multimodal (accepting text or image inputs and outputting text), and it has the same high intelligence as GPT-4 Turbo but is cheaper and more efficient.",
|
|
116
|
+
input: {
|
|
117
|
+
costPer1MTokens: 2.5,
|
|
118
|
+
maxTokens: 128000,
|
|
119
|
+
},
|
|
120
|
+
output: {
|
|
121
|
+
costPer1MTokens: 10,
|
|
122
|
+
maxTokens: 16384,
|
|
123
|
+
},
|
|
124
|
+
tags: ['recommended', 'vision', 'general-purpose', 'coding', 'agents', 'function-calling'],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
fetchModelPreferences: async () => ({
|
|
128
|
+
best: ['openai:gpt-4o-2024-11-20'] as const,
|
|
129
|
+
fast: ['openai:gpt-4o-2024-11-20'] as const,
|
|
130
|
+
downtimes: [],
|
|
131
|
+
}),
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const getCognitiveClient = () => {
|
|
135
|
+
const cognitive = new Cognitive({
|
|
136
|
+
client: new Client({
|
|
137
|
+
apiUrl: process.env.CLOUD_API_ENDPOINT ?? 'https://api.botpress.dev',
|
|
138
|
+
botId: process.env.CLOUD_BOT_ID,
|
|
139
|
+
token: process.env.CLOUD_PAT,
|
|
140
|
+
}),
|
|
141
|
+
provider: cognitiveProvider,
|
|
142
|
+
})
|
|
143
|
+
return cognitive
|
|
144
|
+
}
|
|
145
|
+
|
|
105
146
|
export const getCachedCognitiveClient = () => {
|
|
106
147
|
const cognitive = new Cognitive({
|
|
107
148
|
client: new CachedClient({
|
|
@@ -109,34 +150,7 @@ export const getCachedCognitiveClient = () => {
|
|
|
109
150
|
botId: process.env.CLOUD_BOT_ID,
|
|
110
151
|
token: process.env.CLOUD_PAT,
|
|
111
152
|
}),
|
|
112
|
-
provider:
|
|
113
|
-
deleteModelPreferences: async () => {},
|
|
114
|
-
saveModelPreferences: async () => {},
|
|
115
|
-
fetchInstalledModels: async () => [
|
|
116
|
-
{
|
|
117
|
-
ref: 'openai:gpt-4o-2024-11-20',
|
|
118
|
-
integration: 'openai',
|
|
119
|
-
id: 'gpt-4o-2024-11-20',
|
|
120
|
-
name: 'GPT-4o (November 2024)',
|
|
121
|
-
description:
|
|
122
|
-
"GPT-4o (“o” for “omni”) is OpenAI's most advanced model. It is multimodal (accepting text or image inputs and outputting text), and it has the same high intelligence as GPT-4 Turbo but is cheaper and more efficient.",
|
|
123
|
-
input: {
|
|
124
|
-
costPer1MTokens: 2.5,
|
|
125
|
-
maxTokens: 128000,
|
|
126
|
-
},
|
|
127
|
-
output: {
|
|
128
|
-
costPer1MTokens: 10,
|
|
129
|
-
maxTokens: 16384,
|
|
130
|
-
},
|
|
131
|
-
tags: ['recommended', 'vision', 'general-purpose', 'coding', 'agents', 'function-calling'],
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
fetchModelPreferences: async () => ({
|
|
135
|
-
best: ['openai:gpt-4o-2024-11-20'] as const,
|
|
136
|
-
fast: ['openai:gpt-4o-2024-11-20'] as const,
|
|
137
|
-
downtimes: [],
|
|
138
|
-
}),
|
|
139
|
-
},
|
|
153
|
+
provider: cognitiveProvider,
|
|
140
154
|
})
|
|
141
155
|
return cognitive
|
|
142
156
|
}
|