@budibase/frontend-core 3.23.0 → 3.23.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "3.23.0",
3
+ "version": "3.23.2",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -17,5 +17,5 @@
17
17
  "shortid": "2.2.15",
18
18
  "socket.io-client": "^4.7.5"
19
19
  },
20
- "gitHead": "18f752a8c015ddfff03824f887db75deccb1e7ff"
20
+ "gitHead": "938751f16b9c7ada6baba3dd5525b3cd6256a604"
21
21
  }
package/src/api/agents.ts CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  AgentToolSource,
4
4
  AgentToolSourceWithTools,
5
5
  ChatAgentRequest,
6
- ChatAgentResponse,
7
6
  CreateToolSourceRequest,
8
7
  FetchAgentHistoryResponse,
9
8
  LLMStreamChunk,
@@ -13,7 +12,6 @@ import { Header } from "@budibase/shared-core"
13
12
  import { BaseAPIClient } from "./types"
14
13
 
15
14
  export interface AgentEndpoints {
16
- agentChat: (chat: AgentChat) => Promise<ChatAgentResponse>
17
15
  agentChatStream: (
18
16
  chat: AgentChat,
19
17
  workspaceId: string,
@@ -33,14 +31,6 @@ export interface AgentEndpoints {
33
31
  }
34
32
 
35
33
  export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
36
- agentChat: async chat => {
37
- const body: ChatAgentRequest = chat
38
- return await API.post({
39
- url: "/api/agent/chat",
40
- body,
41
- })
42
- },
43
-
44
34
  agentChatStream: async (chat, workspaceId, onChunk, onError) => {
45
35
  const body: ChatAgentRequest = chat
46
36
 
@@ -58,6 +48,11 @@ export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
58
48
  })
59
49
 
60
50
  if (!response.ok) {
51
+ const body = await response.json()
52
+
53
+ if (body.message) {
54
+ throw new Error(body.message)
55
+ }
61
56
  throw new Error(`HTTP error! status: ${response.status}`)
62
57
  }
63
58
 
@@ -0,0 +1,45 @@
1
+ import {
2
+ AIConfigListResponse,
3
+ CustomAIProviderConfig,
4
+ CreateAIConfigRequest,
5
+ UpdateAIConfigRequest,
6
+ } from "@budibase/types"
7
+
8
+ import { BaseAPIClient } from "./types"
9
+
10
+ export interface AIConfigEndpoints {
11
+ fetch: () => Promise<AIConfigListResponse>
12
+ create: (config: CreateAIConfigRequest) => Promise<CustomAIProviderConfig>
13
+ update: (config: UpdateAIConfigRequest) => Promise<CustomAIProviderConfig>
14
+ delete: (id: string) => Promise<{ deleted: true }>
15
+ }
16
+
17
+ export const buildAIConfigEndpoints = (
18
+ API: BaseAPIClient
19
+ ): AIConfigEndpoints => ({
20
+ fetch: async () => {
21
+ return await API.get({
22
+ url: `/api/configs`,
23
+ })
24
+ },
25
+
26
+ create: async config => {
27
+ return await API.post({
28
+ url: `/api/configs`,
29
+ body: config,
30
+ })
31
+ },
32
+
33
+ update: async config => {
34
+ return await API.put({
35
+ url: `/api/configs`,
36
+ body: config,
37
+ })
38
+ },
39
+
40
+ delete: async id => {
41
+ return await API.delete({
42
+ url: `/api/configs/${id}`,
43
+ })
44
+ },
45
+ })
package/src/api/index.ts CHANGED
@@ -54,6 +54,7 @@ import { buildResourceEndpoints } from "./resource"
54
54
  import { buildDeploymentEndpoints } from "./deploy"
55
55
  import { buildWorkspaceFavouriteEndpoints } from "./workspaceFavourites"
56
56
  import { buildRecaptchaEndpoints } from "./recaptcha"
57
+ import { buildAIConfigEndpoints } from "./aiConfig"
57
58
 
58
59
  export type { APIClient } from "./types"
59
60
 
@@ -308,5 +309,6 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
308
309
  workspace: buildWorkspaceFavouriteEndpoints(API),
309
310
  resource: buildResourceEndpoints(API),
310
311
  recaptcha: buildRecaptchaEndpoints(API),
312
+ aiConfig: buildAIConfigEndpoints(API),
311
313
  }
312
314
  }
package/src/api/types.ts CHANGED
@@ -41,6 +41,7 @@ import { ResourceEndpoints } from "./resource"
41
41
  import { DeploymentEndpoints } from "./deploy"
42
42
  import { WorkspaceFavouriteEndpoints } from "./workspaceFavourites"
43
43
  import { RecaptchaEndpoints } from "./recaptcha"
44
+ import { AIConfigEndpoints } from "./aiConfig"
44
45
 
45
46
  export enum HTTPMethod {
46
47
  POST = "POST",
@@ -153,4 +154,5 @@ export type APIClient = BaseAPIClient &
153
154
  workspace: WorkspaceFavouriteEndpoints
154
155
  deployment: DeploymentEndpoints
155
156
  recaptcha: RecaptchaEndpoints
157
+ aiConfig: AIConfigEndpoints
156
158
  }