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:
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 carries a type field that identifies the event. For example, response.output_text.delta events carry incremental output text in a delta field, and a response.completed event signals the end of the stream.