Examples: Parsing a Streamed Response
Scenario: You receive streamed (SSE-style) responses from an action and want to parse it into objects.
An HTTP action returns a streamed response in this format:
You want to produce:
thread_idfrom the first objectdatefrom the first objecttextas a concatenation of all chunk values
Approach
Treat the streamed output as a JSON array encoded as text:
- Remove the data: prefix
- Create JSON Strings
- Parse with $PARSE_JSON()
- Extract metadata from index [0] and chunks from [1:]
In your compound action the return can reference the SSE action
Or