Responses
The Responses class provides methods to reason over the content in a knowledge store and generate responses.
Methods
Create a response
Description: This method uses Jockey to reason over content in a knowledge store and create a response. It uses Open Responses conventions for input items and streaming events.
Before you use this method, you must create an asset, create a knowledge store, and add the asset to the knowledge store as an item.
Multi-turn conversations: Supported via a session identifier. The first request implicitly creates a session; subsequent requests pass the returned identifier to continue the conversation.
Selections: By default, Jockey reasons over every item in the knowledge store. To narrow the scope, set the optional selections parameter to specific items or item collections, then reference each one with a {{sel:N}} token in the content field of an input item (N is the zero-based position in the selections array). The narrowing is applied at the prompt level; the knowledge store does not block access to other items.
Streaming: To receive the response as Server-Sent Events (SSE), use Stream a response.
Function signature and example:
Parameters
The ResponseInputItem object contains the following properties:
The ResponseSelection object contains the following properties:
The TextParam object contains the following property:
When format.type is json_schema, the format object contains the following properties:
Return value
Returns a ResponseObject object. The ResponseObject object contains the following properties:
The ResponseOutputItem object contains the following properties:
The ResponseOutputContentPart object contains the following properties:
For the full list of fields on each citation in the annotations array, see Create a response.
API Reference
Related guide
Stream a response
Description: This method uses Jockey to reason over content in a knowledge store and create a response, streamed as Server-Sent Events (SSE). It returns an async-iterable stream of ResponseStreamEvent objects. For the non-streaming variant, see Create a response.
Function signature and example:
Parameters
This method accepts the same parameters as Create a response.
Return value
Returns an async-iterable Stream<ResponseStreamEvent>. Each event has a type field that identifies the event; unlike the response object, events have no object field. For example, response.output_text.delta events deliver incremental output text in a delta field, and a response.completed event signals the end of the stream. When you request intermediate outputs, the response.output_item.added event delivers each message with its phase field already set, so you can identify intermediate output or the answer before any of its text streams in. Citations do not stream in with the text: the annotations array is empty while a content part is being generated, and the response.content_part.done event contains the completed part with all of its citations.