@sap-ai-sdk/orchestration
Version:
SAP Cloud SDK for AI is the official Software Development Kit (SDK) for **SAP AI Core**, **SAP Generative AI Hub**, and **Orchestration Service**.
107 lines • 4.71 kB
TypeScript
import type { HttpResponse } from '@sap-cloud-sdk/http-client';
import type { AssistantChatMessage, ChatMessages, CompletionPostResponse, LlmChoice, MessageToolCalls, ModuleResults, TokenUsage, Citation, Error as OrchestrationError } from './client/api/schema/index.js';
import type { OrchestrationStream } from './orchestration-stream.js';
/**
* Orchestration stream response.
*/
export declare class OrchestrationStreamResponse<T> {
_openStream: boolean;
_data: Partial<CompletionPostResponse>;
private _stream;
private _rawResponse;
/**
* @deprecated 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.
*/
constructor();
/**
* Creates an orchestration stream response.
* @param rawResponse - The raw HTTP response from the orchestration service. SSE data is not part of the immediate response.
*/
constructor(rawResponse: HttpResponse);
/**
* Gets the raw HTTP response from the orchestration service. SSE data is not part of the immediate response.
* @returns The raw HTTP response.
* @throws {Error} When OrchestrationStreamResponse was constructed without a raw response parameter (deprecated).
*/
get rawResponse(): HttpResponse;
/**
* Gets the token usage for the response.
* @returns The token usage for the response.
*/
getTokenUsage(): TokenUsage | undefined;
/**
* Gets the request ID for the stream response.
* @returns The request ID, or undefined if the first chunk has not been received yet.
*/
getRequestId(): string | undefined;
/**
* Gets the finish reason for a specific choice index.
* @param choiceIndex - The index of the choice to get the finish reason for.
* @returns The finish reason for the specified choice index.
*/
getFinishReason(choiceIndex?: number): string | undefined;
/**
* Parses the orchestration response and returns the content.
* If the response was filtered, an error is thrown.
* @param choiceIndex - The index of the choice to parse.
* @returns The message content.
*/
getContent(choiceIndex?: number): string | undefined;
/**
* Parses the orchestration response and returns the tool calls generated by the model.
* @param choiceIndex - The index of the choice to parse.
* @returns The message tool calls.
*/
getToolCalls(choiceIndex?: number): MessageToolCalls | undefined;
/**
* Parses the orchestration response and returns the refusal message generated by the model.
* @param choiceIndex - The index of the choice to parse.
* @returns The refusal string.
*/
getRefusal(choiceIndex?: number): string | undefined;
/**
* Messages that can be used for subsequent prompts as message history.
* @param choiceIndex - The index of the choice to parse.
* @returns A list of all messages.
*/
getAllMessages(choiceIndex?: number): ChatMessages | undefined;
/**
* Gets the assistant message from the response.
* @param choiceIndex - The index of the choice to use (default is 0).
* @returns The assistant message.
*/
getAssistantMessage(choiceIndex?: number): AssistantChatMessage | undefined;
/**
* Gets the intermediate results from the orchestration response.
* @returns The intermediate results.
*/
getIntermediateResults(): ModuleResults | undefined;
/**
* 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 The intermediate failures, or undefined if there were none.
*/
getIntermediateFailures(): OrchestrationError[] | undefined;
/**
* Parses the response and returns the choice by index.
* @param index - The index of the choice to find.
* @returns An {@link LLMChoice} object associated with the index.
*/
findChoiceByIndex(index: number): LlmChoice | undefined;
/**
* Gets the citations from the orchestration response.
* Citations are returned by models like Perplexity Sonar that provide source references.
* @returns The citations, or undefined if there are none.
*/
getCitations(): Citation[] | undefined;
get stream(): OrchestrationStream<T>;
/**
* @internal
*/
set stream(stream: OrchestrationStream<T>);
private getChoices;
private isStreamOpen;
}
//# sourceMappingURL=orchestration-stream-response.d.ts.map