Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/update-workflows-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@llamaindex/workflows-client": minor
---


57 changes: 47 additions & 10 deletions packages/workflows-client/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.0",
"info": {
"title": "Workflows API",
"version": "2.8.3"
"version": "2.9.0"
},
"components": {
"schemas": {
Expand Down Expand Up @@ -337,7 +337,7 @@
"/events/{handler_id}": {
"get": {
"summary": "Stream workflow events",
"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",
"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",
"parameters": [
{
"in": "path",
Expand Down Expand Up @@ -377,6 +377,16 @@
"default": 1
},
"description": "Timeout for acquiring the lock to iterate over the events."
},
{
"in": "query",
"name": "include_qualified_name",
"required": false,
"schema": {
"type": "boolean",
"default": true
},
"description": "If true, include the qualified name of the event in the response body."
}
],
"responses": {
Expand All @@ -392,14 +402,25 @@
"type": "object",
"description": "The event value."
},
"type": {
"type": "string",
"description": "The class name of the event."
},
"types": {
"type": "array",
"description": "Superclass names from MRO (excluding the event class and base Event).",
"items": {
"type": "string"
}
},
"qualified_name": {
"type": "string",
"description": "The qualified name of the event."
}
},
"required": [
"value",
"qualified_name"
"type"
]
}
}
Expand Down Expand Up @@ -432,14 +453,30 @@
"type": "object",
"properties": {
"event": {
"type": "string",
"description": "Serialized event in JSON format.",
"examples": {
"type": "event_name",
"data": {
"key": "value"
"description": "Serialized event. Accepts object or JSON-encoded string for backward compatibility.",
"oneOf": [
{
"type": "string",
"description": "JSON string of the event envelope or value.",
"examples": [
"{\"type\": \"ExternalEvent\", \"value\": {\"response\": \"hi\"}}"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The class name of the event."
},
"value": {
"type": "object",
"description": "The event value object (preferred over data)."
}
},
"additionalProperties": true
}
}
]
},
"step": {
"type": "string",
Expand Down
17 changes: 9 additions & 8 deletions packages/workflows-client/src/generated/client/utils.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import { getUrl } from '../core/utils.gen';
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';

export const createQuerySerializer = <T = unknown>({
allowReserved,
array,
object,
parameters = {},
...args
}: QuerySerializerOptions = {}) => {
const querySerializer = (queryParams: T) => {
const search: string[] = [];
Expand All @@ -26,29 +25,31 @@ export const createQuerySerializer = <T = unknown>({
continue;
}

const options = parameters[name] || args;

if (Array.isArray(value)) {
const serializedArray = serializeArrayParam({
allowReserved,
allowReserved: options.allowReserved,
explode: true,
name,
style: 'form',
value,
...array,
...options.array,
});
if (serializedArray) search.push(serializedArray);
} else if (typeof value === 'object') {
const serializedObject = serializeObjectParam({
allowReserved,
allowReserved: options.allowReserved,
explode: true,
name,
style: 'deepObject',
value: value as Record<string, unknown>,
...object,
...options.object,
});
if (serializedObject) search.push(serializedObject);
} else {
const serializedPrimitive = serializePrimitiveParam({
allowReserved,
allowReserved: options.allowReserved,
name,
value: value as string,
});
Expand Down
16 changes: 12 additions & 4 deletions packages/workflows-client/src/generated/core/bodySerializer.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ export type QuerySerializer = (query: Record<string, unknown>) => string;

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

export interface QuerySerializerOptions {
type QuerySerializerOptionsObject = {
allowReserved?: boolean;
array?: SerializerOptions<ArrayStyle>;
object?: SerializerOptions<ObjectStyle>;
}
array?: Partial<SerializerOptions<ArrayStyle>>;
object?: Partial<SerializerOptions<ObjectStyle>>;
};

export type QuerySerializerOptions = QuerySerializerOptionsObject & {
/**
* Per-parameter serialization overrides. When provided, these settings
* override the global array/object settings for specific parameter names.
*/
parameters?: Record<string, QuerySerializerOptionsObject>;
};

const serializeFormDataPair = (
data: FormData,
Expand Down
7 changes: 3 additions & 4 deletions packages/workflows-client/src/generated/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ export const getResultsByHandlerId = <ThrowOnError extends boolean = false>(opti
* Event data is returned as an envelope that preserves backward-compatible fields
* and adds metadata for type-safety on the client:
* {
* "__is_pydantic": true,
* "value": <pydantic serialized value>,
* "qualified_name": <python path to pydantic class>, # deprecated, prefer `mro`
* "mro": [<qualified class names from most to least specific>],
* "origin": "builtin" | "user"
* "types": [<class names from MRO excluding the event class and base Event>],
* "type": <class name>,
* "qualified_name": <python module path + class name>,
* }
*
* Event queue is mutable. Elements are added to the queue by the workflow handler, and removed by any consumer of the queue.
Expand Down
32 changes: 29 additions & 3 deletions packages/workflows-client/src/generated/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ export type GetEventsByHandlerIdData = {
* Timeout for acquiring the lock to iterate over the events.
*/
acquire_timeout?: number;
/**
* If true, include the qualified name of the event in the response body.
*/
include_qualified_name?: boolean;
};
url: '/events/{handler_id}';
};
Expand All @@ -277,10 +281,18 @@ export type GetEventsByHandlerIdResponses = {
value: {
[key: string]: unknown;
};
/**
* The class name of the event.
*/
type: string;
/**
* Superclass names from MRO (excluding the event class and base Event).
*/
types?: Array<string>;
/**
* The qualified name of the event.
*/
qualified_name: string;
qualified_name?: string;
};
};

Expand All @@ -289,9 +301,23 @@ export type GetEventsByHandlerIdResponse = GetEventsByHandlerIdResponses[keyof G
export type PostEventsByHandlerIdData = {
body: {
/**
* Serialized event in JSON format.
* Serialized event. Accepts object or JSON-encoded string for backward compatibility.
*/
event: string;
event: string | {
/**
* The class name of the event.
*/
type?: string;
/**
* The event value object (preferred over data).
*/
value?: {
[key: string]: unknown;
};
[key: string]: unknown | string | {
[key: string]: unknown;
} | undefined;
};
/**
* Optional target step name. If not provided, event is sent to all steps.
*/
Expand Down