SAP AI SDK for JavaScript - v2.15.0
    Preparing search index...

    Class OrchestrationStreamResponse<T>

    Orchestration stream response.

    Type Parameters

    • T
    Index
    • Type Parameters

      • T

      Returns OrchestrationStreamResponse<T>

      Since v2.6.0. Provide an HttpResponse parameter when constructing OrchestrationStreamResponse. This constructor overload will be removed in v3.0.0. Creates an orchestration stream response.

    • Creates an orchestration stream response.

      Type Parameters

      • T

      Parameters

      • rawResponse: HttpResponse

        The raw HTTP response from the orchestration service. SSE data is not part of the immediate response.

      Returns OrchestrationStreamResponse<T>

    _data: Partial<CompletionPostResponse>
    _openStream: boolean
    • get rawResponse(): HttpResponse

      Gets the raw HTTP response from the orchestration service. SSE data is not part of the immediate response.

      Returns HttpResponse

      The raw HTTP response.

      When OrchestrationStreamResponse was constructed without a raw response parameter (deprecated).

    • Parses the response and returns the choice by index.

      Parameters

      • index: number

        The index of the choice to find.

      Returns LlmChoice | undefined

      An LLMChoice object associated with the index.

    • Messages that can be used for subsequent prompts as message history. When reasoning content is present, it is automatically included in the returned messages. Pass the result directly as messagesHistory in the next request to maintain reasoning context. Only available after the stream has been fully consumed.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns ChatMessages | undefined

      A list of all messages including any reasoning content, or undefined if the stream is still open.

    • Gets the assistant message from the response.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to use (default is 0).

      Returns AssistantChatMessage | undefined

      The assistant message.

    • Gets the citations from the orchestration response. Citations are returned by models like Perplexity Sonar that provide source references.

      Returns Citation[] | undefined

      The citations, or undefined if there are none.

    • Parses the orchestration response and returns the content. If the response was filtered, an error is thrown.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns string | undefined

      The message content.

    • Gets the finish reason for a specific choice index.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to get the finish reason for.

      Returns string | undefined

      The finish reason for the specified choice index.

    • Gets the intermediate failures from the orchestration response. When using module fallback, this contains errors from module configurations that failed before a successful one was found.

      Returns OrchestrationError[] | undefined

      The intermediate failures, or undefined if there were none.

    • Gets the intermediate results from the orchestration response.

      Returns ModuleResults | undefined

      The intermediate results.

    • Parses the orchestration stream response and returns the accumulated reasoning content generated by the model. Only available after the stream has been fully consumed. Returns only the user-visible reasoning text; encrypted or redacted reasoning blocks are excluded. To get reasoning content incrementally during streaming, use getDeltaReasoningContent on each chunk instead.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns string[] | undefined

      The content of each reasoning block as an array, or undefined if no reasoning content is present.

    • Parses the orchestration response and returns the refusal message generated by the model.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns string | undefined

      The refusal string.

    • Gets the request ID for the stream response.

      Returns string | undefined

      The request ID, or undefined if the first chunk has not been received yet.

    • Gets the token usage for the response.

      Returns TokenUsage | undefined

      The token usage for the response.

    • Parses the orchestration response and returns the tool calls generated by the model.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns MessageToolCalls | undefined

      The message tool calls.