@botpress/zai 1.0.1-beta.4 → 1.0.1-beta.7

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,76 +0,0 @@
1
- import { Client } from '@botpress/client'
2
-
3
- import { orderBy, isArray } from 'lodash-es'
4
- import fs from 'node:fs'
5
-
6
- const LLM_LIST_MODELS = 'listLanguageModels'
7
-
8
- const client = new Client({
9
- apiUrl: process.env.CLOUD_API_ENDPOINT,
10
- botId: process.env.CLOUD_BOT_ID,
11
- token: process.env.CLOUD_PAT
12
- })
13
-
14
- const { bot } = await client.getBot({
15
- id: process.env.CLOUD_BOT_ID!
16
- })
17
-
18
- type Model = {
19
- id: string
20
- name: string
21
- integration: string
22
- input: { maxTokens: number }
23
- output: { maxTokens: number }
24
- }
25
-
26
- const models: Model[] = []
27
-
28
- for (const integrationId in bot.integrations) {
29
- const botIntegration = bot.integrations[integrationId]
30
- if (botIntegration?.public && botIntegration?.enabled && botIntegration?.status === 'registered') {
31
- try {
32
- const { integration } = await client.getPublicIntegrationById({
33
- id: botIntegration.id
34
- })
35
-
36
- const canListModels = Object.keys(integration.actions).includes(LLM_LIST_MODELS)
37
- if (!canListModels) {
38
- continue
39
- }
40
-
41
- const { output } = await client.callAction({
42
- type: `${integration.name}:${LLM_LIST_MODELS}`,
43
- input: {}
44
- })
45
-
46
- if (isArray(output?.models)) {
47
- for (const model of output.models) {
48
- models.push({
49
- id: `${integration.name}__${model.id}`,
50
- name: model.name,
51
- integration: integration.name,
52
- input: { maxTokens: model.input.maxTokens },
53
- output: { maxTokens: model.output.maxTokens }
54
- })
55
- }
56
- }
57
- } catch (err: unknown) {
58
- console.error('Error fetching integration:', err instanceof Error ? err.message : `${err}`)
59
- }
60
- }
61
- }
62
-
63
- const content = JSON.stringify(orderBy(models, ['integration', 'name']), null, 2)
64
-
65
- fs.writeFileSync(
66
- './src/models.ts',
67
- `
68
- // This file is generated. Do not edit it manually.
69
- // See 'scripts/update-models.ts'
70
-
71
- /* eslint-disable */
72
- /* tslint:disable */
73
-
74
- export const Models = ${content} as const`,
75
- 'utf-8'
76
- )
@@ -1,49 +0,0 @@
1
- import { Client } from '@botpress/client'
2
- import { z } from '@bpinternal/zui'
3
-
4
- import { maxBy } from 'lodash-es'
5
- import fs from 'node:fs'
6
- import path from 'node:path'
7
-
8
- const Interfaces = ['llm'] as const
9
-
10
- const client = new Client({
11
- apiUrl: process.env.CLOUD_API_ENDPOINT,
12
- botId: process.env.CLOUD_BOT_ID,
13
- token: process.env.CLOUD_PAT
14
- })
15
-
16
- for (const name of Interfaces) {
17
- const { interfaces } = await client.listInterfaces({
18
- name
19
- })
20
-
21
- const { interface: latest } = await client.getInterface({
22
- id: maxBy(interfaces, 'version')!.id
23
- })
24
-
25
- for (const action of Object.keys(latest.actions)) {
26
- const references = Object.keys(latest.entities).reduce((acc, key) => {
27
- return { ...acc, [key]: z.fromJsonSchema(latest.entities?.[key]?.schema!) }
28
- }, {})
29
- const input = latest.actions[action]?.input.schema!
30
- const output = latest.actions[action]?.output.schema!
31
-
32
- const types = `
33
- // This file is generated. Do not edit it manually.
34
- // See 'scripts/update-models.ts'
35
-
36
- /* eslint-disable */
37
- /* tslint:disable */
38
-
39
- export namespace ${name} {
40
- export namespace ${action} {
41
- export ${z.fromJsonSchema(input).title('Input').dereference(references).toTypescript({ declaration: 'type' })};
42
- export ${z.fromJsonSchema(output).title('Output').dereference(references).toTypescript({ declaration: 'type' })};
43
- }
44
- }`
45
-
46
- fs.mkdirSync(path.resolve(`./src/sdk-interfaces/${name}`), { recursive: true })
47
- fs.writeFileSync(path.resolve(`./src/sdk-interfaces/${name}/${action}.ts`), types)
48
- }
49
- }
package/tsup.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
-
3
- export default defineConfig({
4
- entry: ['src/index.ts'],
5
- splitting: false,
6
- format: ['esm', 'cjs'],
7
- sourcemap: true,
8
- keepNames: true,
9
- dts: true,
10
- platform: 'browser',
11
- clean: true,
12
- shims: true,
13
- external: ['react', 'react-dom'],
14
- bundle: true,
15
- plugins: []
16
- })
package/vitest.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import 'dotenv/config'
2
- import { defineConfig } from 'vitest/config'
3
-
4
- export default defineConfig({
5
- test: {
6
- include: ['./src/**/*.test.ts'],
7
- setupFiles: './vitest.setup.ts'
8
- }
9
- })
package/vitest.setup.ts DELETED
@@ -1,24 +0,0 @@
1
- import { Client } from '@botpress/client'
2
- import { setupClient } from '@botpress/vai'
3
-
4
- import { beforeAll } from 'vitest'
5
-
6
- globalThis.STUDIO = false
7
-
8
- beforeAll(async () => {
9
- if (!process.env.CLOUD_PAT) {
10
- throw new Error('Missing CLOUD_PAT')
11
- }
12
-
13
- if (!process.env.CLOUD_BOT_ID) {
14
- throw new Error('Missing CLOUD_BOT_ID')
15
- }
16
-
17
- setupClient(
18
- new Client({
19
- apiUrl: process.env.CLOUD_API_ENDPOINT ?? 'https://api.botpress.dev',
20
- botId: process.env.CLOUD_BOT_ID,
21
- token: process.env.CLOUD_PAT
22
- })
23
- )
24
- })
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes