@vertesia/workflow 0.45.2 → 0.46.0

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 (48) hide show
  1. package/lib/cjs/activities/executeInteraction.js.map +1 -1
  2. package/lib/cjs/activities/generateEmbeddings.js.map +1 -1
  3. package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -1
  4. package/lib/cjs/dsl/setup/fetch/index.js.map +1 -1
  5. package/lib/cjs/dsl/setup/fetch/providers.js.map +1 -1
  6. package/lib/cjs/iterative-generation/utils.js.map +1 -1
  7. package/lib/cjs/utils/blobs.js.map +1 -1
  8. package/lib/cjs/utils/client.js +1 -1
  9. package/lib/cjs/utils/client.js.map +1 -1
  10. package/lib/cjs/utils/memory.js.map +1 -1
  11. package/lib/esm/activities/executeInteraction.js.map +1 -1
  12. package/lib/esm/activities/generateEmbeddings.js.map +1 -1
  13. package/lib/esm/dsl/setup/ActivityContext.js.map +1 -1
  14. package/lib/esm/dsl/setup/fetch/index.js.map +1 -1
  15. package/lib/esm/dsl/setup/fetch/providers.js.map +1 -1
  16. package/lib/esm/iterative-generation/utils.js.map +1 -1
  17. package/lib/esm/utils/blobs.js.map +1 -1
  18. package/lib/esm/utils/client.js +2 -2
  19. package/lib/esm/utils/client.js.map +1 -1
  20. package/lib/esm/utils/memory.js.map +1 -1
  21. package/lib/types/activities/executeInteraction.d.ts +2 -2
  22. package/lib/types/activities/executeInteraction.d.ts.map +1 -1
  23. package/lib/types/dsl/setup/ActivityContext.d.ts +3 -3
  24. package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -1
  25. package/lib/types/dsl/setup/fetch/index.d.ts +3 -3
  26. package/lib/types/dsl/setup/fetch/index.d.ts.map +1 -1
  27. package/lib/types/dsl/setup/fetch/providers.d.ts +10 -10
  28. package/lib/types/dsl/setup/fetch/providers.d.ts.map +1 -1
  29. package/lib/types/iterative-generation/utils.d.ts +3 -3
  30. package/lib/types/iterative-generation/utils.d.ts.map +1 -1
  31. package/lib/types/utils/blobs.d.ts +6 -6
  32. package/lib/types/utils/blobs.d.ts.map +1 -1
  33. package/lib/types/utils/client.d.ts +2 -2
  34. package/lib/types/utils/client.d.ts.map +1 -1
  35. package/lib/types/utils/memory.d.ts +5 -5
  36. package/lib/types/utils/memory.d.ts.map +1 -1
  37. package/lib/workflows-bundle.js +30 -17
  38. package/package.json +3 -3
  39. package/src/activities/executeInteraction.ts +3 -3
  40. package/src/activities/generateEmbeddings.ts +3 -3
  41. package/src/dsl/setup/ActivityContext.ts +4 -4
  42. package/src/dsl/setup/fetch/index.ts +4 -4
  43. package/src/dsl/setup/fetch/providers.ts +7 -7
  44. package/src/dsl/workflow-fetch.test.ts +2 -2
  45. package/src/iterative-generation/utils.ts +3 -3
  46. package/src/utils/blobs.ts +6 -6
  47. package/src/utils/client.ts +2 -2
  48. package/src/utils/memory.ts +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/workflow",
3
- "version": "0.45.2",
3
+ "version": "0.46.0",
4
4
  "type": "module",
5
5
  "description": "Composable prompts workflow dsl",
6
6
  "main": "./lib/esm/index.js",
@@ -49,9 +49,9 @@
49
49
  "tiktoken": "^1.0.15",
50
50
  "tmp": "^0.2.3",
51
51
  "yaml": "^2.6.0",
52
- "@vertesia/common": "0.45.2",
52
+ "@vertesia/common": "0.46.0",
53
53
  "@llumiverse/core": "0.15.0",
54
- "@vertesia/client": "0.45.2"
54
+ "@vertesia/client": "0.46.0"
55
55
  },
56
56
  "ts_dual_module": {
57
57
  "outDir": "lib",
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from "@vertesia/client";
1
+ import { VertesiaClient } from "@vertesia/client";
2
2
  import { DSLActivityExecutionPayload, DSLActivitySpec, ExecutionRun, ExecutionRunStatus, InteractionExecutionConfiguration, RunSearchPayload } from "@vertesia/common";
3
3
  import { activityInfo, log } from "@temporalio/activity";
4
4
  import { projectResult } from "../dsl/projections.js";
@@ -53,7 +53,7 @@ const JSON: DSLActivitySpec = {
53
53
  }
54
54
  }
55
55
 
56
- export interface InteractionExecutionParams extends ModelOptions{
56
+ export interface InteractionExecutionParams extends ModelOptions {
57
57
  /**
58
58
  * The environment to use. If not specified the project default environment will be used.
59
59
  * If the latter is not specified an exeption will be thrown.
@@ -117,7 +117,7 @@ export async function executeInteraction(payload: DSLActivityExecutionPayload) {
117
117
 
118
118
  }
119
119
 
120
- export async function executeInteractionFromActivity(client: ComposableClient, interactionName: string, params: InteractionExecutionParams, prompt_data: any, debug?: boolean) {
120
+ export async function executeInteractionFromActivity(client: VertesiaClient, interactionName: string, params: InteractionExecutionParams, prompt_data: any, debug?: boolean) {
121
121
  const userTags = params.tags;
122
122
  const info = activityInfo();
123
123
  const runId = info.workflowExecution.runId;
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from "@vertesia/client";
1
+ import { VertesiaClient } from "@vertesia/client";
2
2
  import { ContentObject, DSLActivityExecutionPayload, DSLActivitySpec, ProjectConfigurationEmbeddings, SupportedEmbeddingTypes } from "@vertesia/common";
3
3
  import { EmbeddingsResult } from "@llumiverse/core";
4
4
  import { log } from "@temporalio/activity";
@@ -96,7 +96,7 @@ export async function generateEmbeddings(payload: DSLActivityExecutionPayload) {
96
96
 
97
97
  interface ExecuteGenerateEmbeddingsParams {
98
98
  document: ContentObject;
99
- client: ComposableClient;
99
+ client: VertesiaClient;
100
100
  type: SupportedEmbeddingTypes;
101
101
  config: ProjectConfigurationEmbeddings;
102
102
  property?: string;
@@ -297,7 +297,7 @@ async function generateImageEmbeddings({ document, client, type, config }: Execu
297
297
 
298
298
  }
299
299
 
300
- async function generateEmbeddingsFromStudio(text: string, env: string, client: ComposableClient, model?: string): Promise<EmbeddingsResult> {
300
+ async function generateEmbeddingsFromStudio(text: string, env: string, client: VertesiaClient, model?: string): Promise<EmbeddingsResult> {
301
301
 
302
302
  log.info(`Generating embeddings for text of ${text.length} chars with environment ${env}`);
303
303
 
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from "@vertesia/client";
1
+ import { VertesiaClient } from "@vertesia/client";
2
2
  import { DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, Project, WorkflowExecutionPayload } from "@vertesia/common";
3
3
  import { log } from "@temporalio/activity";
4
4
  import { NoDocumentFound, WorkflowParamNotFound } from "../../errors.js";
@@ -14,10 +14,10 @@ registerFetchProviderFactory(DocumentTypeProvider.ID, DocumentTypeProvider.facto
14
14
  registerFetchProviderFactory(InteractionRunProvider.ID, InteractionRunProvider.factory);
15
15
 
16
16
  export class ActivityContext<T extends Record<string, any> = Record<string, any>> {
17
- client: ComposableClient;
17
+ client: VertesiaClient;
18
18
  _project?: Promise<Project | undefined>;
19
19
 
20
- constructor(public payload: DSLActivityExecutionPayload, client: ComposableClient, public params: T) {
20
+ constructor(public payload: DSLActivityExecutionPayload, client: VertesiaClient, public params: T) {
21
21
  this.client = client;
22
22
  this.fetchProject = this.fetchProject.bind(this);
23
23
  }
@@ -100,7 +100,7 @@ export async function setupActivity<T extends Record<string, any> = Record<strin
100
100
  }
101
101
 
102
102
 
103
- async function _fetchProject(client: ComposableClient, payload: WorkflowExecutionPayload) {
103
+ async function _fetchProject(client: VertesiaClient, payload: WorkflowExecutionPayload) {
104
104
  const project = await getProjectFromToken(payload.auth_token);
105
105
  return project ? await client.projects.retrieve(project.id) : undefined;
106
106
  }
@@ -1,16 +1,16 @@
1
1
  import { ActivityFetchSpec } from "@vertesia/common";
2
- import { ComposableClient } from "@vertesia/client";
2
+ import { VertesiaClient } from "@vertesia/client";
3
3
  import { DataProvider } from "./DataProvider.js";
4
4
 
5
5
 
6
- const factories: Record<string, ((client: ComposableClient, source?: string) => DataProvider)> = {};
6
+ const factories: Record<string, ((client: VertesiaClient, source?: string) => DataProvider)> = {};
7
7
 
8
8
 
9
- export function registerFetchProviderFactory(name: string, factory: ((client: ComposableClient) => DataProvider)) {
9
+ export function registerFetchProviderFactory(name: string, factory: ((client: VertesiaClient) => DataProvider)) {
10
10
  factories[name] = factory;
11
11
  }
12
12
 
13
- export function getFetchProvider(client: ComposableClient, fetchSpec: ActivityFetchSpec) {
13
+ export function getFetchProvider(client: VertesiaClient, fetchSpec: ActivityFetchSpec) {
14
14
  const factory = factories[fetchSpec.type];
15
15
  if (!factory) {
16
16
  throw new Error("Unknown data provider: " + fetchSpec.source);
@@ -1,5 +1,5 @@
1
1
  import { FindPayload } from "@vertesia/common";
2
- import { ComposableClient } from "@vertesia/client";
2
+ import { VertesiaClient } from "@vertesia/client";
3
3
  import { DataProvider } from "./DataProvider.js";
4
4
 
5
5
  function useMongoId(query: Record<string, any>) {
@@ -13,7 +13,7 @@ function useMongoId(query: Record<string, any>) {
13
13
 
14
14
  export class DocumentProvider extends DataProvider {
15
15
  static ID = "document";
16
- constructor(public client: ComposableClient) {
16
+ constructor(public client: VertesiaClient) {
17
17
  super(DocumentProvider.ID, true);
18
18
  }
19
19
 
@@ -24,14 +24,14 @@ export class DocumentProvider extends DataProvider {
24
24
  });
25
25
  }
26
26
 
27
- static factory(client: ComposableClient) {
27
+ static factory(client: VertesiaClient) {
28
28
  return new DocumentProvider(client);
29
29
  }
30
30
  }
31
31
 
32
32
  export class DocumentTypeProvider extends DataProvider {
33
33
  static ID = "document_type";
34
- constructor(public client: ComposableClient) {
34
+ constructor(public client: VertesiaClient) {
35
35
  super(DocumentTypeProvider.ID, true);
36
36
  }
37
37
 
@@ -42,14 +42,14 @@ export class DocumentTypeProvider extends DataProvider {
42
42
  });
43
43
  }
44
44
 
45
- static factory(client: ComposableClient) {
45
+ static factory(client: VertesiaClient) {
46
46
  return new DocumentTypeProvider(client);
47
47
  }
48
48
  }
49
49
 
50
50
  export class InteractionRunProvider extends DataProvider {
51
51
  static ID = "interaction_run";
52
- constructor(public client: ComposableClient) {
52
+ constructor(public client: VertesiaClient) {
53
53
  super(DocumentProvider.ID, true);
54
54
  }
55
55
 
@@ -60,7 +60,7 @@ export class InteractionRunProvider extends DataProvider {
60
60
  });
61
61
  }
62
62
 
63
- static factory(client: ComposableClient) {
63
+ static factory(client: VertesiaClient) {
64
64
  return new InteractionRunProvider(client);
65
65
  }
66
66
 
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from '@vertesia/client';
1
+ import { VertesiaClient } from '@vertesia/client';
2
2
  import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload, FindPayload } from '@vertesia/common';
3
3
  import { TestWorkflowEnvironment } from '@temporalio/testing';
4
4
  import { Worker } from '@temporalio/worker';
@@ -27,7 +27,7 @@ class DocumentTestProvider extends DataProvider {
27
27
  }
28
28
  }
29
29
 
30
- static factory(_context: ComposableClient) {
30
+ static factory(_context: VertesiaClient) {
31
31
  return new DocumentTestProvider();
32
32
  }
33
33
  }
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from "@vertesia/client";
1
+ import { VertesiaClient } from "@vertesia/client";
2
2
  import { ExecutionRun } from "@vertesia/common";
3
3
  import { ApplicationFailure } from "@temporalio/workflow";
4
4
  import { OutputMemoryMeta, PartIndex, Toc, TocIndex, TocSection } from "./types.js";
@@ -14,7 +14,7 @@ export interface ExecuteOptions {
14
14
  result_schema?: Record<string, any>;
15
15
  }
16
16
 
17
- export async function execute<T = any>(client: ComposableClient, options: ExecuteOptions): Promise<ExecutionRun<any, T>> {
17
+ export async function execute<T = any>(client: VertesiaClient, options: ExecuteOptions): Promise<ExecutionRun<any, T>> {
18
18
  return client.interactions.executeByName(options.interaction, {
19
19
  data: {
20
20
  ...options.memory_mapping,
@@ -30,7 +30,7 @@ export async function execute<T = any>(client: ComposableClient, options: Execut
30
30
  });
31
31
  }
32
32
 
33
- export function executeWithVars<T = any>(client: ComposableClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun<any, T>> {
33
+ export function executeWithVars<T = any>(client: VertesiaClient, interaction: string, vars: Record<string, any>, mapping?: Record<string, any>, result_schema?: Record<string, any>): Promise<ExecutionRun<any, T>> {
34
34
  if (mapping) {
35
35
  mapping = { ...vars.input_mapping, ...mapping };
36
36
  } else {
@@ -1,4 +1,4 @@
1
- import { ComposableClient } from "@vertesia/client";
1
+ import { VertesiaClient } from "@vertesia/client";
2
2
  import crypto from "crypto";
3
3
  import { createWriteStream } from "fs";
4
4
  import tmp from "tmp";
@@ -6,14 +6,14 @@ import { NoDocumentFound } from "../errors.js";
6
6
 
7
7
  tmp.setGracefulCleanup();
8
8
 
9
- export async function fetchBlobAsStream(client: ComposableClient, blobUri: string): Promise<ReadableStream<Uint8Array>> {
9
+ export async function fetchBlobAsStream(client: VertesiaClient, blobUri: string): Promise<ReadableStream<Uint8Array>> {
10
10
  try {
11
11
  return await client.files.downloadFile(blobUri);
12
12
  } catch (err: any) {
13
13
  throw new NoDocumentFound(`Blob ${blobUri} not found`, []);
14
14
  }
15
15
  }
16
- export async function fetchBlobAsBuffer(client: ComposableClient, blobUri: string): Promise<Buffer> {
16
+ export async function fetchBlobAsBuffer(client: VertesiaClient, blobUri: string): Promise<Buffer> {
17
17
  let stream = await fetchBlobAsStream(client, blobUri);
18
18
  const buffers: Uint8Array[] = [];
19
19
  for await (const data of stream) {
@@ -22,18 +22,18 @@ export async function fetchBlobAsBuffer(client: ComposableClient, blobUri: strin
22
22
  return Buffer.concat(buffers);
23
23
  }
24
24
 
25
- export async function fetchBlobAsBase64(client: ComposableClient, blobUri: string): Promise<string> {
25
+ export async function fetchBlobAsBase64(client: VertesiaClient, blobUri: string): Promise<string> {
26
26
  const buffer = await fetchBlobAsBuffer(client, blobUri);
27
27
  return buffer.toString('base64');
28
28
  }
29
29
 
30
- export async function saveBlobToFile(client: ComposableClient, blobUri: string, toFile: string): Promise<void> {
30
+ export async function saveBlobToFile(client: VertesiaClient, blobUri: string, toFile: string): Promise<void> {
31
31
  let stream = await fetchBlobAsStream(client, blobUri);
32
32
  const out = createWriteStream(toFile);
33
33
  await writeChunksToStream(stream, out);
34
34
  }
35
35
 
36
- export async function saveBlobToTempFile(client: ComposableClient, blobUri: string, fileExt?: string): Promise<string> {
36
+ export async function saveBlobToTempFile(client: VertesiaClient, blobUri: string, fileExt?: string): Promise<string> {
37
37
  const tmpFile = tmp.fileSync({
38
38
  prefix: "composable-activity-",
39
39
  postfix: fileExt,
@@ -2,7 +2,7 @@
2
2
  * get a zeno client for a given token
3
3
  */
4
4
 
5
- import { ComposableClient } from "@vertesia/client";
5
+ import { VertesiaClient } from "@vertesia/client";
6
6
  import { WorkflowExecutionPayload } from "@vertesia/common";
7
7
 
8
8
 
@@ -20,7 +20,7 @@ export function getClient(payload: WorkflowExecutionPayload) {
20
20
  throw new Error("Content Store URL is missing from WorkflowExecutionPayload.servers.storeUrl");
21
21
  }
22
22
 
23
- const client = new ComposableClient({
23
+ const client = new VertesiaClient({
24
24
  serverUrl: payload.config.studio_url,
25
25
  storeUrl: payload.config.store_url,
26
26
  apikey: payload.auth_token
@@ -1,4 +1,4 @@
1
- import { ComposableClient, StreamSource } from "@vertesia/client";
1
+ import { VertesiaClient, StreamSource } from "@vertesia/client";
2
2
  import { Commands, MemoryPack, buildMemoryPack as _buildMemoryPack, loadMemoryPack as _loadMemoryPack } from "@vertesia/memory";
3
3
  import { createReadStream, createWriteStream } from "fs";
4
4
  import { rm } from "fs/promises";
@@ -17,7 +17,7 @@ export class NodeStreamSource extends StreamSource {
17
17
  }
18
18
  }
19
19
 
20
- export async function publishMemoryPack(client: ComposableClient, file: string, name: string): Promise<void> {
20
+ export async function publishMemoryPack(client: VertesiaClient, file: string, name: string): Promise<void> {
21
21
  const stream = createReadStream(file);
22
22
  try {
23
23
  const source = new NodeStreamSource(stream, name);
@@ -39,7 +39,7 @@ export async function buildMemoryPack(recipeFn: (commands: Commands) => Promise<
39
39
  });
40
40
  }
41
41
 
42
- export async function buildAndPublishMemoryPack(client: ComposableClient, name: string, recipeFn: (commands: Commands) => Promise<Record<string, any>>): Promise<void> {
42
+ export async function buildAndPublishMemoryPack(client: VertesiaClient, name: string, recipeFn: (commands: Commands) => Promise<Record<string, any>>): Promise<void> {
43
43
  const tarFile = await buildMemoryPack(recipeFn);
44
44
  try {
45
45
  await publishMemoryPack(client, tarFile, name);
@@ -48,7 +48,7 @@ export async function buildAndPublishMemoryPack(client: ComposableClient, name:
48
48
  }
49
49
  }
50
50
 
51
- export async function fetchMemoryPack(client: ComposableClient, name: string): Promise<string> {
51
+ export async function fetchMemoryPack(client: VertesiaClient, name: string): Promise<string> {
52
52
  const webStream = await client.files.downloadMemoryPack(name);
53
53
  const tarFile = tmp.fileSync({
54
54
  prefix: "composable-memory-pack-",
@@ -61,6 +61,6 @@ export async function fetchMemoryPack(client: ComposableClient, name: string): P
61
61
  return tarFile.name;
62
62
  }
63
63
 
64
- export function loadMemoryPack(client: ComposableClient, name: string): Promise<MemoryPack> {
64
+ export function loadMemoryPack(client: VertesiaClient, name: string): Promise<MemoryPack> {
65
65
  return fetchMemoryPack(client, name).then(file => _loadMemoryPack(file));
66
66
  }