@vertesia/client 0.42.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.
Files changed (193) hide show
  1. package/LICENSE +13 -0
  2. package/lib/cjs/AccountApi.js +66 -0
  3. package/lib/cjs/AccountApi.js.map +1 -0
  4. package/lib/cjs/AccountsApi.js +13 -0
  5. package/lib/cjs/AccountsApi.js.map +1 -0
  6. package/lib/cjs/AnalyticsApi.js +13 -0
  7. package/lib/cjs/AnalyticsApi.js.map +1 -0
  8. package/lib/cjs/ApiKeysApi.js +63 -0
  9. package/lib/cjs/ApiKeysApi.js.map +1 -0
  10. package/lib/cjs/CommandsApi.js +19 -0
  11. package/lib/cjs/CommandsApi.js.map +1 -0
  12. package/lib/cjs/EnvironmentsApi.js +58 -0
  13. package/lib/cjs/EnvironmentsApi.js.map +1 -0
  14. package/lib/cjs/IamApi.js +51 -0
  15. package/lib/cjs/IamApi.js.map +1 -0
  16. package/lib/cjs/InteractionBase.js +44 -0
  17. package/lib/cjs/InteractionBase.js.map +1 -0
  18. package/lib/cjs/InteractionsApi.js +184 -0
  19. package/lib/cjs/InteractionsApi.js.map +1 -0
  20. package/lib/cjs/ProjectsApi.js +48 -0
  21. package/lib/cjs/ProjectsApi.js.map +1 -0
  22. package/lib/cjs/PromptsApi.js +133 -0
  23. package/lib/cjs/PromptsApi.js.map +1 -0
  24. package/lib/cjs/RefsApi.js +14 -0
  25. package/lib/cjs/RefsApi.js.map +1 -0
  26. package/lib/cjs/RunsApi.js +79 -0
  27. package/lib/cjs/RunsApi.js.map +1 -0
  28. package/lib/cjs/StreamSource.js +17 -0
  29. package/lib/cjs/StreamSource.js.map +1 -0
  30. package/lib/cjs/TrainingApi.js +54 -0
  31. package/lib/cjs/TrainingApi.js.map +1 -0
  32. package/lib/cjs/UsersApi.js +13 -0
  33. package/lib/cjs/UsersApi.js.map +1 -0
  34. package/lib/cjs/client.js +161 -0
  35. package/lib/cjs/client.js.map +1 -0
  36. package/lib/cjs/execute.js +146 -0
  37. package/lib/cjs/execute.js.map +1 -0
  38. package/lib/cjs/index.js +22 -0
  39. package/lib/cjs/index.js.map +1 -0
  40. package/lib/cjs/package.json +3 -0
  41. package/lib/cjs/store/CommandsApi.js +33 -0
  42. package/lib/cjs/store/CommandsApi.js.map +1 -0
  43. package/lib/cjs/store/FilesApi.js +122 -0
  44. package/lib/cjs/store/FilesApi.js.map +1 -0
  45. package/lib/cjs/store/ObjectsApi.js +185 -0
  46. package/lib/cjs/store/ObjectsApi.js.map +1 -0
  47. package/lib/cjs/store/TypesApi.js +52 -0
  48. package/lib/cjs/store/TypesApi.js.map +1 -0
  49. package/lib/cjs/store/WorkflowsApi.js +92 -0
  50. package/lib/cjs/store/WorkflowsApi.js.map +1 -0
  51. package/lib/cjs/store/client.js +49 -0
  52. package/lib/cjs/store/client.js.map +1 -0
  53. package/lib/cjs/store/errors.js +11 -0
  54. package/lib/cjs/store/errors.js.map +1 -0
  55. package/lib/cjs/store/index.js +22 -0
  56. package/lib/cjs/store/index.js.map +1 -0
  57. package/lib/esm/AccountApi.js +63 -0
  58. package/lib/esm/AccountApi.js.map +1 -0
  59. package/lib/esm/AccountsApi.js +10 -0
  60. package/lib/esm/AccountsApi.js.map +1 -0
  61. package/lib/esm/AnalyticsApi.js +10 -0
  62. package/lib/esm/AnalyticsApi.js.map +1 -0
  63. package/lib/esm/ApiKeysApi.js +59 -0
  64. package/lib/esm/ApiKeysApi.js.map +1 -0
  65. package/lib/esm/CommandsApi.js +16 -0
  66. package/lib/esm/CommandsApi.js.map +1 -0
  67. package/lib/esm/EnvironmentsApi.js +55 -0
  68. package/lib/esm/EnvironmentsApi.js.map +1 -0
  69. package/lib/esm/IamApi.js +45 -0
  70. package/lib/esm/IamApi.js.map +1 -0
  71. package/lib/esm/InteractionBase.js +40 -0
  72. package/lib/esm/InteractionBase.js.map +1 -0
  73. package/lib/esm/InteractionsApi.js +181 -0
  74. package/lib/esm/InteractionsApi.js.map +1 -0
  75. package/lib/esm/ProjectsApi.js +45 -0
  76. package/lib/esm/ProjectsApi.js.map +1 -0
  77. package/lib/esm/PromptsApi.js +130 -0
  78. package/lib/esm/PromptsApi.js.map +1 -0
  79. package/lib/esm/RefsApi.js +10 -0
  80. package/lib/esm/RefsApi.js.map +1 -0
  81. package/lib/esm/RunsApi.js +75 -0
  82. package/lib/esm/RunsApi.js.map +1 -0
  83. package/lib/esm/StreamSource.js +13 -0
  84. package/lib/esm/StreamSource.js.map +1 -0
  85. package/lib/esm/TrainingApi.js +51 -0
  86. package/lib/esm/TrainingApi.js.map +1 -0
  87. package/lib/esm/UsersApi.js +10 -0
  88. package/lib/esm/UsersApi.js.map +1 -0
  89. package/lib/esm/client.js +154 -0
  90. package/lib/esm/client.js.map +1 -0
  91. package/lib/esm/execute.js +108 -0
  92. package/lib/esm/execute.js.map +1 -0
  93. package/lib/esm/index.js +6 -0
  94. package/lib/esm/index.js.map +1 -0
  95. package/lib/esm/store/CommandsApi.js +28 -0
  96. package/lib/esm/store/CommandsApi.js.map +1 -0
  97. package/lib/esm/store/FilesApi.js +117 -0
  98. package/lib/esm/store/FilesApi.js.map +1 -0
  99. package/lib/esm/store/ObjectsApi.js +181 -0
  100. package/lib/esm/store/ObjectsApi.js.map +1 -0
  101. package/lib/esm/store/TypesApi.js +48 -0
  102. package/lib/esm/store/TypesApi.js.map +1 -0
  103. package/lib/esm/store/WorkflowsApi.js +86 -0
  104. package/lib/esm/store/WorkflowsApi.js.map +1 -0
  105. package/lib/esm/store/client.js +45 -0
  106. package/lib/esm/store/client.js.map +1 -0
  107. package/lib/esm/store/errors.js +7 -0
  108. package/lib/esm/store/errors.js.map +1 -0
  109. package/lib/esm/store/index.js +6 -0
  110. package/lib/esm/store/index.js.map +1 -0
  111. package/lib/tsconfig.tsbuildinfo +1 -0
  112. package/lib/types/AccountApi.d.ts +43 -0
  113. package/lib/types/AccountApi.d.ts.map +1 -0
  114. package/lib/types/AccountsApi.d.ts +6 -0
  115. package/lib/types/AccountsApi.d.ts.map +1 -0
  116. package/lib/types/AnalyticsApi.d.ts +6 -0
  117. package/lib/types/AnalyticsApi.d.ts.map +1 -0
  118. package/lib/types/ApiKeysApi.d.ts +42 -0
  119. package/lib/types/ApiKeysApi.d.ts.map +1 -0
  120. package/lib/types/CommandsApi.d.ts +10 -0
  121. package/lib/types/CommandsApi.d.ts.map +1 -0
  122. package/lib/types/EnvironmentsApi.d.ts +30 -0
  123. package/lib/types/EnvironmentsApi.d.ts.map +1 -0
  124. package/lib/types/IamApi.d.ts +39 -0
  125. package/lib/types/IamApi.d.ts.map +1 -0
  126. package/lib/types/InteractionBase.d.ts +22 -0
  127. package/lib/types/InteractionBase.d.ts.map +1 -0
  128. package/lib/types/InteractionsApi.d.ts +129 -0
  129. package/lib/types/InteractionsApi.d.ts.map +1 -0
  130. package/lib/types/ProjectsApi.d.ts +17 -0
  131. package/lib/types/ProjectsApi.d.ts.map +1 -0
  132. package/lib/types/PromptsApi.d.ts +106 -0
  133. package/lib/types/PromptsApi.d.ts.map +1 -0
  134. package/lib/types/RefsApi.d.ts +6 -0
  135. package/lib/types/RefsApi.d.ts.map +1 -0
  136. package/lib/types/RunsApi.d.ts +62 -0
  137. package/lib/types/RunsApi.d.ts.map +1 -0
  138. package/lib/types/StreamSource.d.ts +7 -0
  139. package/lib/types/StreamSource.d.ts.map +1 -0
  140. package/lib/types/TrainingApi.d.ts +27 -0
  141. package/lib/types/TrainingApi.d.ts.map +1 -0
  142. package/lib/types/UsersApi.d.ts +6 -0
  143. package/lib/types/UsersApi.d.ts.map +1 -0
  144. package/lib/types/client.d.ts +85 -0
  145. package/lib/types/client.d.ts.map +1 -0
  146. package/lib/types/execute.d.ts +32 -0
  147. package/lib/types/execute.d.ts.map +1 -0
  148. package/lib/types/index.d.ts +8 -0
  149. package/lib/types/index.d.ts.map +1 -0
  150. package/lib/types/store/CommandsApi.d.ts +13 -0
  151. package/lib/types/store/CommandsApi.d.ts.map +1 -0
  152. package/lib/types/store/FilesApi.d.ts +41 -0
  153. package/lib/types/store/FilesApi.d.ts.map +1 -0
  154. package/lib/types/store/ObjectsApi.d.ts +76 -0
  155. package/lib/types/store/ObjectsApi.d.ts.map +1 -0
  156. package/lib/types/store/TypesApi.d.ts +13 -0
  157. package/lib/types/store/TypesApi.d.ts.map +1 -0
  158. package/lib/types/store/WorkflowsApi.d.ts +39 -0
  159. package/lib/types/store/WorkflowsApi.d.ts.map +1 -0
  160. package/lib/types/store/client.d.ts +23 -0
  161. package/lib/types/store/client.d.ts.map +1 -0
  162. package/lib/types/store/errors.d.ts +4 -0
  163. package/lib/types/store/errors.d.ts.map +1 -0
  164. package/lib/types/store/index.d.ts +5 -0
  165. package/lib/types/store/index.d.ts.map +1 -0
  166. package/package.json +36 -0
  167. package/src/AccountApi.ts +75 -0
  168. package/src/AccountsApi.ts +18 -0
  169. package/src/AnalyticsApi.ts +20 -0
  170. package/src/ApiKeysApi.ts +67 -0
  171. package/src/CommandsApi.ts +23 -0
  172. package/src/EnvironmentsApi.ts +70 -0
  173. package/src/IamApi.ts +68 -0
  174. package/src/InteractionBase.ts +44 -0
  175. package/src/InteractionsApi.ts +210 -0
  176. package/src/ProjectsApi.ts +58 -0
  177. package/src/PromptsApi.ts +160 -0
  178. package/src/RefsApi.ts +18 -0
  179. package/src/RunsApi.ts +103 -0
  180. package/src/StreamSource.ts +3 -0
  181. package/src/TrainingApi.ts +71 -0
  182. package/src/UsersApi.ts +18 -0
  183. package/src/client.ts +191 -0
  184. package/src/execute.ts +114 -0
  185. package/src/index.ts +8 -0
  186. package/src/store/CommandsApi.ts +42 -0
  187. package/src/store/FilesApi.ts +139 -0
  188. package/src/store/ObjectsApi.ts +245 -0
  189. package/src/store/TypesApi.ts +61 -0
  190. package/src/store/WorkflowsApi.ts +121 -0
  191. package/src/store/client.ts +61 -0
  192. package/src/store/errors.ts +7 -0
  193. package/src/store/index.ts +6 -0
@@ -0,0 +1,4 @@
1
+ import { RequestError } from "@vertesia/api-fetch-client";
2
+ export declare class ZenoClientNotFoundError extends RequestError {
3
+ constructor(req: Request, error: RequestError);
4
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/store/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,qBAAa,uBAAwB,SAAQ,YAAY;gBACzC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY;CAGhD"}
@@ -0,0 +1,5 @@
1
+ export * from "./client.js";
2
+ export * from "./CommandsApi.js";
3
+ export * from "./ObjectsApi.js";
4
+ export * from "./TypesApi.js";
5
+ export * from "./WorkflowsApi.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@vertesia/client",
3
+ "version": "0.42.2",
4
+ "type": "module",
5
+ "types": "./lib/types/index.d.ts",
6
+ "files": [
7
+ "lib",
8
+ "src"
9
+ ],
10
+ "devDependencies": {
11
+ "@types/eventsource": "^1.1.14",
12
+ "@types/node": "^20.8.9",
13
+ "ts-dual-module": "^0.6.3",
14
+ "typescript": "^5.0.2",
15
+ "vitest": "^2.1.6"
16
+ },
17
+ "dependencies": {
18
+ "eventsource": "^2.0.2",
19
+ "@vertesia/common": "0.42.2",
20
+ "@vertesia/api-fetch-client": "0.42.2",
21
+ "@llumiverse/core": "0.15.0"
22
+ },
23
+ "ts_dual_module": {
24
+ "outDir": "lib"
25
+ },
26
+ "exports": {
27
+ "types": "./lib/types/index.d.ts",
28
+ "import": "./lib/esm/index.js",
29
+ "require": "./lib/cjs/index.js"
30
+ },
31
+ "scripts": {
32
+ "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
33
+ "build": "pnpm exec tsmod build",
34
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
35
+ }
36
+ }
@@ -0,0 +1,75 @@
1
+ import { Account, InviteUserRequestPayload, InviteUserResponsePayload, OnboardingProgress, ProjectRef, TransientToken, UpdateAccountPayload, User, UserInviteTokenData } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
3
+
4
+ export default class AccountApi extends ApiTopic {
5
+
6
+ constructor(parent: ClientBase) {
7
+ super(parent, "/api/v1/account")
8
+ }
9
+
10
+ /**
11
+ * Retrieve all account information for current account
12
+ * @returns Account[]
13
+ */
14
+ info(): Promise<Account> {
15
+ return this.get('/');
16
+ }
17
+
18
+ /**
19
+ * Update account information
20
+ * @returns Account
21
+ */
22
+ update(payload: UpdateAccountPayload): Promise<Account> {
23
+ return this.put('/', { payload });
24
+ }
25
+
26
+ /**
27
+ * Get all projects for account
28
+ */
29
+ projects(): Promise<ProjectRef[]> {
30
+ return this.get('/projects').then(res => res.data);
31
+ }
32
+
33
+ members(): Promise<User[]> {
34
+ return this.get('/members')
35
+ }
36
+
37
+ /**
38
+ * Invite User to account
39
+ */
40
+ inviteUser(payload: InviteUserRequestPayload): Promise<InviteUserResponsePayload> {
41
+ return this.post('/invites', { payload });
42
+ }
43
+
44
+ /**
45
+ * Fetch Invites for account
46
+ * @returns UserInviteTokenData[]
47
+ * */
48
+ listInvites(): Promise<TransientToken<UserInviteTokenData>[]> {
49
+ return this.get('/invites');
50
+ }
51
+
52
+ /**
53
+ * Accept Invite for account
54
+ * @returns UserInviteTokenData
55
+ * */
56
+ acceptInvite(id: string): Promise<UserInviteTokenData> {
57
+ return this.put(`/invites/${id}`);
58
+ }
59
+
60
+ /**
61
+ * Delete Invite for account
62
+ * @returns UserInviteTokenData
63
+ * */
64
+ rejectInvite(id: string): Promise<UserInviteTokenData> {
65
+ return this.delete(`/invites/${id}`);
66
+ }
67
+
68
+ /**
69
+ * Get Onboarding Progress for account
70
+ */
71
+ onboardingProgress(): Promise<OnboardingProgress> {
72
+ return this.get('/onboarding');
73
+ }
74
+
75
+ }
@@ -0,0 +1,18 @@
1
+ import { Account } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
3
+
4
+ export default class AccountsApi extends ApiTopic {
5
+
6
+ constructor(parent: ClientBase) {
7
+ super(parent, "/api/v1/accounts")
8
+ }
9
+
10
+ create(name: string): Promise<Account> {
11
+ return this.post('/', { payload: { name } });
12
+ }
13
+
14
+
15
+
16
+
17
+
18
+ }
@@ -0,0 +1,20 @@
1
+ import { RunAnalyticsQuery, RunAnalyticsResult } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
3
+
4
+
5
+
6
+
7
+ export default class AnalyticsApi extends ApiTopic {
8
+
9
+ constructor(parent: ClientBase) {
10
+ super(parent, "/api/v1/analytics")
11
+ }
12
+
13
+ runs(params: RunAnalyticsQuery): Promise<RunAnalyticsResult[]> {
14
+
15
+ return this.post('/runs', { payload: params });
16
+
17
+ }
18
+
19
+
20
+ }
@@ -0,0 +1,67 @@
1
+ import { ApiKey, ApiKeyWithValue, CreateOrUpdateApiKeyPayload, CreatePublicKeyPayload } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
3
+
4
+ export class ApiKeysApi extends ApiTopic {
5
+
6
+
7
+ constructor(parent: ClientBase) {
8
+ super(parent, "/api/v1/apikeys")
9
+ }
10
+
11
+
12
+ /**
13
+ * List all keys for account without values
14
+ * @returns ApiKey[]
15
+ */
16
+ list(): Promise<ApiKey[]> {
17
+ return this.get('/');
18
+ }
19
+
20
+ /**
21
+ * Create an new ApiKey for account
22
+ * BE VERY CAREFUL USING THIS API
23
+ * ALL REQUESTS ARE LOGGED IN SECURITY AUDIT LOG
24
+ * @returns ApiKeyWithValue
25
+ */
26
+ create(payload: CreateOrUpdateApiKeyPayload): Promise<ApiKeyWithValue> {
27
+ return this.post('/', { payload });
28
+ }
29
+
30
+ /**
31
+ * Update an existing ApiKey for account
32
+ * @returns ApiKey
33
+ */
34
+ update(id: string, payload: CreateOrUpdateApiKeyPayload): Promise<ApiKey> {
35
+ return this.put(`/${id}`, { payload });
36
+ }
37
+
38
+ /**
39
+ * Retrieve an ApiKey and its value
40
+ * BE VERY CAREFUL USING THIS API AS IT EXPOSE THE API KEY VALUE
41
+ * ALL REQUESTS ARE LOGGED IN SECURITY AUDIT LOG
42
+ * @returns ApiKeyWithValue
43
+ * */
44
+ retrieve(id: string, withValue: boolean = false): Promise<ApiKey | ApiKeyWithValue> {
45
+ if (withValue) {
46
+ return this.get(`/${id}`, { query: { withValue: true } });
47
+ } else {
48
+ return this.get(`/${id}`);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * get or create a temporary public key which can be used from browser to browse and execute itneractions.
54
+ * If a public key already exists for the given project (or for the current organization) then it is returned, otherwise a new one is created.
55
+ * The payload object can contain the following properties:
56
+ * - name: the name of the public key. If not specified a random name is generated.
57
+ * - projectId: the id of the project to which the public key will be associated.
58
+ * If not specified the key is associated with the current organization. (i.e. account).
59
+ * - ttl: the time to live of the public key in seconds.
60
+ * The ttl defaults to 1h.
61
+ * @param opts
62
+ * @returns
63
+ */
64
+ requestPublicKey(payload: CreatePublicKeyPayload = {}): Promise<string> {
65
+ return this.get('/pk', { query: payload as Record<string, string | number> });
66
+ }
67
+ }
@@ -0,0 +1,23 @@
1
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
2
+ import { GenericCommandResponse } from "@vertesia/common";
3
+
4
+
5
+ /**
6
+ * Various utility commands
7
+ */
8
+
9
+ export default class CommandsApi extends ApiTopic {
10
+
11
+ constructor(parent: ClientBase) {
12
+ super(parent, "/api/v1/commands")
13
+ }
14
+
15
+ async isNamespaceAvailable(name: string): Promise<boolean> {
16
+ return this.get(`/namespaces/${name}/is_available`).then((response) => response.available);
17
+ }
18
+
19
+ async initSamples(): Promise<GenericCommandResponse> {
20
+ return this.post("/onboarding/init-samples");
21
+ }
22
+
23
+ }
@@ -0,0 +1,70 @@
1
+ import { ExecutionEnvironment, ExecutionEnvironmentCreatePayload, ExecutionEnvironmentRef, ExecutionEnvironmentUpdatePayload, LoadBalancingEnvConfig, MediatorEnvConfig } from "@vertesia/common";
2
+ import { AIModel, EmbeddingsOptions, EmbeddingsResult, ModelSearchPayload } from "@llumiverse/core";
3
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
4
+
5
+ export default class EnvironmentsApi extends ApiTopic {
6
+ constructor(parent: ClientBase) {
7
+ super(parent, "/api/v1/environments");
8
+ }
9
+
10
+ /**
11
+ * List all environments for the current project
12
+ * @param all if true, list all environments, otherwise only the ones for the current project
13
+ */
14
+ list(all: boolean = false): Promise<ExecutionEnvironmentRef[]> {
15
+ const query = all ? { all: true } : undefined;
16
+
17
+ return this.get('/', { query });
18
+ }
19
+
20
+ create(payload: ExecutionEnvironmentCreatePayload): Promise<ExecutionEnvironment> {
21
+ return this.post('/', {
22
+ payload
23
+ });
24
+ }
25
+
26
+ retrieve(id: string): Promise<ExecutionEnvironment> {
27
+ return this.get('/' + id);
28
+ }
29
+
30
+ update(id: string, payload: ExecutionEnvironmentUpdatePayload): Promise<ExecutionEnvironment> {
31
+ return this.put('/' + id, {
32
+ payload
33
+ });
34
+ }
35
+
36
+ /**
37
+ * udpate enabled models and / or config. If enabled_models is not provided, the existing enabled models will not change.
38
+ * Same, if config is not provioded the exiting config is not changed.
39
+ * If the config is provided then it will be updated without removing fields that are not provided.
40
+ *
41
+ * @param id
42
+ * @param payload
43
+ * @returns
44
+ */
45
+ updateConfig(id: string, payload: {
46
+ enabled_models?: AIModel[],
47
+ config?: MediatorEnvConfig | LoadBalancingEnvConfig
48
+ }): Promise<ExecutionEnvironment> {
49
+ return this.put('/' + id + '/config', {
50
+ payload
51
+ });
52
+ }
53
+
54
+ listModels(id: string, payload?: ModelSearchPayload): Promise<AIModel[]> {
55
+ return this.get('/' + id + '/models', {
56
+ query: payload ? { ...payload } : undefined
57
+ });
58
+ }
59
+
60
+ listTrainableModels(id: string): Promise<AIModel[]> {
61
+ return this.get(`/${id}/trainable-models`);
62
+ }
63
+
64
+ embeddings(id: string, payload?: EmbeddingsOptions): Promise<EmbeddingsResult> {
65
+ return this.post('/' + id + '/embeddings', {
66
+ payload
67
+ });
68
+ }
69
+
70
+ }
package/src/IamApi.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { AccessControlEntry, ACECreatePayload, AcesQueryOptions, Permission, ProjectRoles } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase } from "@vertesia/api-fetch-client";
3
+
4
+
5
+ export interface FilterOption {
6
+ id: string,
7
+ name: string,
8
+ count: number
9
+ }
10
+
11
+
12
+ export class IamApi extends ApiTopic {
13
+
14
+ constructor(parent: ClientBase) {
15
+ super(parent, "/api/v1/iam")
16
+ }
17
+
18
+ aces = new AcesApi(this)
19
+ roles = new RolesApi(this)
20
+ }
21
+
22
+ export class RolesApi extends ApiTopic {
23
+
24
+ constructor(parent: ClientBase) {
25
+ super(parent, "/roles")
26
+ }
27
+
28
+ list(): Promise<{ name: ProjectRoles, permissions: Permission[] }[]> {
29
+ return this.get('/');
30
+ }
31
+
32
+ }
33
+
34
+
35
+ export class AcesApi extends ApiTopic {
36
+
37
+ constructor(parent: ClientBase) {
38
+ super(parent, "/aces")
39
+ }
40
+
41
+ /**
42
+ * Get the list of all runs
43
+ * @param project optional project id to filter by
44
+ * @param interaction optional interaction id to filter by
45
+ * @returns InteractionResult[]
46
+ **/
47
+ list(options: AcesQueryOptions): Promise<AccessControlEntry[]> {
48
+ return this.get('/', { query: { ...options } });
49
+ }
50
+
51
+ /**
52
+ * Get an ACE by its Id
53
+ * @param id
54
+ * @returns InteractionResult
55
+ **/
56
+ retrieve(id: string): Promise<AccessControlEntry> {
57
+ return this.get('/' + id);
58
+ }
59
+
60
+ create(payload: ACECreatePayload): Promise<AccessControlEntry> {
61
+ return this.post('/', { payload })
62
+ }
63
+
64
+ delete(id: string): Promise<{ id: string }> {
65
+ return this.del('/' + id)
66
+ }
67
+
68
+ }
@@ -0,0 +1,44 @@
1
+ import { ExecutionRun, InteractionUpdatePayload, InteractionExecutionPayload } from "@vertesia/common";
2
+ import { ComposableClient, ComposableClientProps } from "./client.js";
3
+ import { executeInteraction } from "./execute.js";
4
+
5
+ export class InteractionBase<P = any, R = any> {
6
+ client: ComposableClient;
7
+
8
+ constructor(public id: string, clientOrOpts: ComposableClient | ComposableClientProps) {
9
+ if (clientOrOpts instanceof ComposableClient) {
10
+ this.client = clientOrOpts;
11
+ } else {
12
+ this.client = new ComposableClient(clientOrOpts);
13
+ }
14
+ }
15
+
16
+ retrieve() {
17
+ return this.client.interactions.retrieve(this.id);
18
+ }
19
+
20
+ update(payload: InteractionUpdatePayload) {
21
+ return this.client.interactions.update(this.id, payload);
22
+ }
23
+
24
+ render(data: P) {
25
+ data;
26
+ //TODO
27
+ }
28
+
29
+ /**
30
+ * Execute an interaction and return a promise which will be resolved with the executed run when
31
+ * the run completes or fails.
32
+ * If the onChunk callback is passed then the streaming of the result is enabled.
33
+ * The onChunk callback with be called with the next chunk of the result as soon as it is available.
34
+ * When all chunks are received the fucntion will return the resolved promise
35
+ * @param id of the interaction to execute
36
+ * @param payload InteractionExecutionPayload
37
+ * @param onChunk callback to be called when the next chunk of the response is available
38
+ * @returns the resolved execution run as Promise<ExecutionRun>
39
+ */
40
+ async execute(payload: InteractionExecutionPayload = {},
41
+ onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
42
+ return executeInteraction<P, R>(this.client, this.id, payload, onChunk);
43
+ }
44
+ }
@@ -0,0 +1,210 @@
1
+ import { ComputeInteractionFacetPayload, ExecutionRun, GenerateInteractionPayload, GenerateTestDataPayload, ImprovePromptPayload, Interaction, InteractionCreatePayload, InteractionExecutionPayload, InteractionForkPayload, InteractionPublishPayload, InteractionRef, InteractionRefWithSchema, InteractionUpdatePayload, InteractionsExportPayload, InteractionSearchPayload, InteractionSearchQuery } from "@vertesia/common";
2
+ import { ApiTopic, ClientBase, ServerError } from "@vertesia/api-fetch-client";
3
+ import { ComposableClient } from "./client.js";
4
+ import { executeInteraction, executeInteractionByName } from "./execute.js";
5
+
6
+ export interface ComputeInteractionFacetsResponse {
7
+ tags?: { _id: string, count: number }[];
8
+ status?: { _id: string, count: number }[];
9
+ total?: { count: number }[];
10
+ }
11
+
12
+ export default class InteractionsApi extends ApiTopic {
13
+ constructor(parent: ClientBase) {
14
+ super(parent, "/api/v1/interactions");
15
+ }
16
+
17
+ /**
18
+ * Get the list of all interactions in the current project
19
+ * @returns InteractionRef[]
20
+ **/
21
+ list(payload: InteractionSearchPayload = {}): Promise<InteractionRef[]> {
22
+ const query = payload.query || {} as InteractionSearchQuery;
23
+
24
+ return this.get("/", {
25
+ query: {
26
+ ...query
27
+ }
28
+ });
29
+ }
30
+
31
+ /**
32
+ * Get the list of all interactions facets
33
+ * @param payload query payload to filter facet search
34
+ * @returns ComputeInteractionFacetsResponse[]
35
+ **/
36
+ computeFacets(query: ComputeInteractionFacetPayload): Promise<ComputeInteractionFacetsResponse> {
37
+ return this.post("/facets", {
38
+ payload: query
39
+ });
40
+ }
41
+
42
+ /**
43
+ * List interaction names in the current project
44
+ * @returns
45
+ */
46
+ listNames(): Promise<{ id: string, name: string }[]> {
47
+ return this.get('/names');
48
+ }
49
+
50
+ /**
51
+ * Get the list of all interactions in the current project. Schemas will be returned too.
52
+ * @returns InteractionRefWithSchema[]
53
+ **/
54
+ export(payload: InteractionsExportPayload): Promise<InteractionRefWithSchema[]> {
55
+ return this.post('/export', { payload });
56
+ }
57
+
58
+ /**
59
+ * Create a new interaction
60
+ * @param payload InteractionCreatePayload
61
+ * @returns Interaction
62
+ * @throws ApiError
63
+ * @throws 400 if payload is invalid
64
+ * @throws 500 if interaction creation fails
65
+ **/
66
+ create(payload: InteractionCreatePayload): Promise<Interaction> {
67
+ return this.post('/', {
68
+ payload
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Retrieve an existing interaction definiton
74
+ * @param id of the interaction to retrieve
75
+ * @returns Interaction
76
+ **/
77
+ retrieve(id: string): Promise<Interaction> {
78
+ return this.get(`/${id}`);
79
+ }
80
+
81
+ /**
82
+ * Update an existing interaction definiton
83
+ * @param id of the interaction to update
84
+ * @param payload InteractionUpdatePayload
85
+ * @returns Interaction
86
+ * @throws ApiError
87
+ * @throws 400 if payload is invalid
88
+ * @throws 500 if interaction update fails
89
+ * @throws 404 if interaction not found
90
+ **/
91
+ update(id: string, payload: InteractionUpdatePayload): Promise<Interaction> {
92
+ return this.put(`/${id}`, {
93
+ payload
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Execute an interaction and return a promise which will be resolved with the executed run when
99
+ * the run completes or fails.
100
+ * If the onChunk callback is passed then the streaming of the result is enabled.
101
+ * The onChunk callback with be called with the next chunk of the result as soon as it is available.
102
+ * When all chunks are received the fucntion will return the resolved promise
103
+ * @param id of the interaction to execute
104
+ * @param payload InteractionExecutionPayload
105
+ * @param onChunk callback to be called when the next chunk of the response is available
106
+ * @returns Promise<ExecutionRun>
107
+ * @throws ApiError
108
+ * @throws 404 if interaction not found
109
+ * @throws 400 if payload is invalid
110
+ * @throws 500 if interaction execution fails
111
+ * @throws 500 if interaction execution times out
112
+ **/
113
+ execute<P = any, R = any>(id: string, payload: InteractionExecutionPayload = {},
114
+ onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
115
+ return executeInteraction(this.client as ComposableClient, id, payload, onChunk).catch(err => {
116
+ if (err instanceof ServerError && err.payload?.id) {
117
+ throw err.updateDetails({ run_id: err.payload.id });
118
+ } else {
119
+ throw err;
120
+ }
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Same as execute but uses the interaction name selector instead of the id.
126
+ *
127
+ * A name selector is the interaction endpoint name suffuxed with an optional tag or version wich is starting with a `@` character.
128
+ * The special `draft` tag is used to select the draft version of the interaction. If no tag or version is specified then the latest version is selected.
129
+ * Examples of selectors:
130
+ * - `ReviewContract` - select the latest version of the ReviewContract interaction
131
+ * - `ReviewContract@1` - select the version 1 of the ReviewContract interaction
132
+ * - `ReviewContract@draft` - select the draft version of the ReviewContract interaction
133
+ * - `ReviewContract@fixed` - select the ReviewContract interaction which is tagged with 'fixed' tag.
134
+ * @param nameWithTag
135
+ * @param payload
136
+ * @param onChunk
137
+ * @returns
138
+ */
139
+ executeByName<P = any, R = any>(nameWithTag: string, payload: InteractionExecutionPayload = {},
140
+ onChunk?: (chunk: string) => void): Promise<ExecutionRun<P, R>> {
141
+ return executeInteractionByName(this.client as ComposableClient, nameWithTag, payload, onChunk).catch(err => {
142
+ if (err instanceof ServerError && err.payload?.id) {
143
+ throw err.updateDetails({ run_id: err.payload.id });
144
+ } else {
145
+ throw err;
146
+ }
147
+ });
148
+ }
149
+
150
+ publish(id: string, payload: InteractionPublishPayload): Promise<Interaction> {
151
+ return this.post(`/${id}/publish`, {
152
+ payload
153
+ });
154
+ }
155
+
156
+ fork(id: string, payload: InteractionForkPayload): Promise<Interaction> {
157
+ return this.post(`/${id}/fork`, {
158
+ payload
159
+ });
160
+ }
161
+
162
+ /**
163
+ * Generate Composable definition of an interaction
164
+ **/
165
+ generateInteraction(id: string, payload: GenerateInteractionPayload): Promise<any[]> {
166
+
167
+ return this.post(`${id}/generate-interaction`, {
168
+ payload
169
+ });
170
+
171
+ }
172
+
173
+ /**
174
+ * Generate Test Data for an interaction
175
+ **/
176
+ generateTestData(id: string, payload: GenerateTestDataPayload): Promise<any[]> {
177
+
178
+ return this.post(`${id}/generate-test-data`, {
179
+ payload
180
+ });
181
+ }
182
+
183
+ /**
184
+ * Suggest Improvement for a prompt
185
+ */
186
+ suggestImprovements(id: string, payload: ImprovePromptPayload): Promise<{ result: string; }> {
187
+ return this.post(`${id}/suggest-prompt-improvements`, {
188
+ payload
189
+ });
190
+ }
191
+
192
+ /**
193
+ * List the versions of the interaction. Returns an empty array if no versions are found
194
+ * @param id
195
+ * @returns the versions list or an empty array if no versions are found
196
+ */
197
+ listVersions(id: string): Promise<InteractionRef[]> {
198
+ return this.get(`/${id}/versions`);
199
+ }
200
+
201
+ /**
202
+ * List the forks of the interaction. Returns an empty array if no forks are found
203
+ * @param id
204
+ * @returns the versions list or an empty array if no forks are found
205
+ */
206
+ listForks(id: string): Promise<InteractionRef[]> {
207
+ return this.get(`/${id}/forks`);
208
+ }
209
+
210
+ }