Skip to content

Commit 764d8dd

Browse files
authored
Merge pull request #155 from run-llama/update-workflows-sdk-2.9.0
chore: update workflows SDK
2 parents d3423fd + 31a2a69 commit 764d8dd

File tree

6 files changed

+105
-29
lines changed

6 files changed

+105
-29
lines changed

.changeset/update-workflows-sdk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@llamaindex/workflows-client": minor
3+
---
4+
5+

packages/workflows-client/openapi.json

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.0.0",
33
"info": {
44
"title": "Workflows API",
5-
"version": "2.8.3"
5+
"version": "2.9.0"
66
},
77
"components": {
88
"schemas": {
@@ -337,7 +337,7 @@
337337
"/events/{handler_id}": {
338338
"get": {
339339
"summary": "Stream workflow events",
340-
"description": "Streams events produced by a workflow execution. Events are emitted as\nnewline-delimited JSON by default, or as Server-Sent Events when `sse=true`.\nEvent data is returned as an envelope that preserves backward-compatible fields\nand adds metadata for type-safety on the client:\n{\n \"__is_pydantic\": true,\n \"value\": <pydantic serialized value>,\n \"qualified_name\": <python path to pydantic class>, # deprecated, prefer `mro`\n \"mro\": [<qualified class names from most to least specific>],\n \"origin\": \"builtin\" | \"user\"\n}\n\nEvent queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.\nThe queue is protected by a lock that is acquired by the consumer, so only one consumer of the queue at a time is allowed.\n",
340+
"description": "Streams events produced by a workflow execution. Events are emitted as\nnewline-delimited JSON by default, or as Server-Sent Events when `sse=true`.\nEvent data is returned as an envelope that preserves backward-compatible fields\nand adds metadata for type-safety on the client:\n{\n \"value\": <pydantic serialized value>,\n \"types\": [<class names from MRO excluding the event class and base Event>],\n \"type\": <class name>,\n \"qualified_name\": <python module path + class name>,\n}\n\nEvent queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.\nThe queue is protected by a lock that is acquired by the consumer, so only one consumer of the queue at a time is allowed.\n",
341341
"parameters": [
342342
{
343343
"in": "path",
@@ -377,6 +377,16 @@
377377
"default": 1
378378
},
379379
"description": "Timeout for acquiring the lock to iterate over the events."
380+
},
381+
{
382+
"in": "query",
383+
"name": "include_qualified_name",
384+
"required": false,
385+
"schema": {
386+
"type": "boolean",
387+
"default": true
388+
},
389+
"description": "If true, include the qualified name of the event in the response body."
380390
}
381391
],
382392
"responses": {
@@ -392,14 +402,25 @@
392402
"type": "object",
393403
"description": "The event value."
394404
},
405+
"type": {
406+
"type": "string",
407+
"description": "The class name of the event."
408+
},
409+
"types": {
410+
"type": "array",
411+
"description": "Superclass names from MRO (excluding the event class and base Event).",
412+
"items": {
413+
"type": "string"
414+
}
415+
},
395416
"qualified_name": {
396417
"type": "string",
397418
"description": "The qualified name of the event."
398419
}
399420
},
400421
"required": [
401422
"value",
402-
"qualified_name"
423+
"type"
403424
]
404425
}
405426
}
@@ -432,14 +453,30 @@
432453
"type": "object",
433454
"properties": {
434455
"event": {
435-
"type": "string",
436-
"description": "Serialized event in JSON format.",
437-
"examples": {
438-
"type": "event_name",
439-
"data": {
440-
"key": "value"
456+
"description": "Serialized event. Accepts object or JSON-encoded string for backward compatibility.",
457+
"oneOf": [
458+
{
459+
"type": "string",
460+
"description": "JSON string of the event envelope or value.",
461+
"examples": [
462+
"{\"type\": \"ExternalEvent\", \"value\": {\"response\": \"hi\"}}"
463+
]
464+
},
465+
{
466+
"type": "object",
467+
"properties": {
468+
"type": {
469+
"type": "string",
470+
"description": "The class name of the event."
471+
},
472+
"value": {
473+
"type": "object",
474+
"description": "The event value object (preferred over data)."
475+
}
476+
},
477+
"additionalProperties": true
441478
}
442-
}
479+
]
443480
},
444481
"step": {
445482
"type": "string",

packages/workflows-client/src/generated/client/utils.gen.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import { getUrl } from '../core/utils.gen';
1212
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
1313

1414
export const createQuerySerializer = <T = unknown>({
15-
allowReserved,
16-
array,
17-
object,
15+
parameters = {},
16+
...args
1817
}: QuerySerializerOptions = {}) => {
1918
const querySerializer = (queryParams: T) => {
2019
const search: string[] = [];
@@ -26,29 +25,31 @@ export const createQuerySerializer = <T = unknown>({
2625
continue;
2726
}
2827

28+
const options = parameters[name] || args;
29+
2930
if (Array.isArray(value)) {
3031
const serializedArray = serializeArrayParam({
31-
allowReserved,
32+
allowReserved: options.allowReserved,
3233
explode: true,
3334
name,
3435
style: 'form',
3536
value,
36-
...array,
37+
...options.array,
3738
});
3839
if (serializedArray) search.push(serializedArray);
3940
} else if (typeof value === 'object') {
4041
const serializedObject = serializeObjectParam({
41-
allowReserved,
42+
allowReserved: options.allowReserved,
4243
explode: true,
4344
name,
4445
style: 'deepObject',
4546
value: value as Record<string, unknown>,
46-
...object,
47+
...options.object,
4748
});
4849
if (serializedObject) search.push(serializedObject);
4950
} else {
5051
const serializedPrimitive = serializePrimitiveParam({
51-
allowReserved,
52+
allowReserved: options.allowReserved,
5253
name,
5354
value: value as string,
5455
});

packages/workflows-client/src/generated/core/bodySerializer.gen.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ export type QuerySerializer = (query: Record<string, unknown>) => string;
1010

1111
export type BodySerializer = (body: any) => any;
1212

13-
export interface QuerySerializerOptions {
13+
type QuerySerializerOptionsObject = {
1414
allowReserved?: boolean;
15-
array?: SerializerOptions<ArrayStyle>;
16-
object?: SerializerOptions<ObjectStyle>;
17-
}
15+
array?: Partial<SerializerOptions<ArrayStyle>>;
16+
object?: Partial<SerializerOptions<ObjectStyle>>;
17+
};
18+
19+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
20+
/**
21+
* Per-parameter serialization overrides. When provided, these settings
22+
* override the global array/object settings for specific parameter names.
23+
*/
24+
parameters?: Record<string, QuerySerializerOptionsObject>;
25+
};
1826

1927
const serializeFormDataPair = (
2028
data: FormData,

packages/workflows-client/src/generated/sdk.gen.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ export const getResultsByHandlerId = <ThrowOnError extends boolean = false>(opti
100100
* Event data is returned as an envelope that preserves backward-compatible fields
101101
* and adds metadata for type-safety on the client:
102102
* {
103-
* "__is_pydantic": true,
104103
* "value": <pydantic serialized value>,
105-
* "qualified_name": <python path to pydantic class>, # deprecated, prefer `mro`
106-
* "mro": [<qualified class names from most to least specific>],
107-
* "origin": "builtin" | "user"
104+
* "types": [<class names from MRO excluding the event class and base Event>],
105+
* "type": <class name>,
106+
* "qualified_name": <python module path + class name>,
108107
* }
109108
*
110109
* Event queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.

packages/workflows-client/src/generated/types.gen.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ export type GetEventsByHandlerIdData = {
255255
* Timeout for acquiring the lock to iterate over the events.
256256
*/
257257
acquire_timeout?: number;
258+
/**
259+
* If true, include the qualified name of the event in the response body.
260+
*/
261+
include_qualified_name?: boolean;
258262
};
259263
url: '/events/{handler_id}';
260264
};
@@ -277,10 +281,18 @@ export type GetEventsByHandlerIdResponses = {
277281
value: {
278282
[key: string]: unknown;
279283
};
284+
/**
285+
* The class name of the event.
286+
*/
287+
type: string;
288+
/**
289+
* Superclass names from MRO (excluding the event class and base Event).
290+
*/
291+
types?: Array<string>;
280292
/**
281293
* The qualified name of the event.
282294
*/
283-
qualified_name: string;
295+
qualified_name?: string;
284296
};
285297
};
286298

@@ -289,9 +301,23 @@ export type GetEventsByHandlerIdResponse = GetEventsByHandlerIdResponses[keyof G
289301
export type PostEventsByHandlerIdData = {
290302
body: {
291303
/**
292-
* Serialized event in JSON format.
304+
* Serialized event. Accepts object or JSON-encoded string for backward compatibility.
293305
*/
294-
event: string;
306+
event: string | {
307+
/**
308+
* The class name of the event.
309+
*/
310+
type?: string;
311+
/**
312+
* The event value object (preferred over data).
313+
*/
314+
value?: {
315+
[key: string]: unknown;
316+
};
317+
[key: string]: unknown | string | {
318+
[key: string]: unknown;
319+
} | undefined;
320+
};
295321
/**
296322
* Optional target step name. If not provided, event is sent to all steps.
297323
*/

0 commit comments

Comments
 (0)