@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/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
  }