@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**.
97 lines • 4.01 kB
TypeScript
import type { HttpResponse } from '@sap-cloud-sdk/http-client';
import type { CompletionPostResponse, TokenUsage, ChatMessages, AssistantChatMessage, MessageToolCalls, LlmChoice, ModuleResults, Error as OrchestrationError, Citation } from './client/api/schema/index.js';
/**
* Representation of an orchestration response.
*/
export declare class OrchestrationResponse {
readonly rawResponse: HttpResponse;
/**
* The completion post response.
*/
readonly _data: CompletionPostResponse;
constructor(rawResponse: HttpResponse);
/**
* Usage of tokens in the response.
* @returns Token usage.
*/
getTokenUsage(): TokenUsage;
/**
* Reason for stopping the completion.
* @param choiceIndex - The index of the choice to parse.
* @returns The finish reason.
*/
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;
/**
* 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;
/**
* 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.
*
* Each failure includes:
* - message: Description of what went wrong
* - code: Error code identifying the type of failure
* - location: Position in the fallback chain (e.g., "config[0]", "config[1]").
* @example
* const response = await client.chatCompletion();
* const failures = response.getIntermediateFailures();
* if (failures) {
* failures.forEach(f => console.log(`${f.location}: ${f.message}`));
* }
* @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 request ID from the orchestration response.
* @returns The request ID.
*/
getRequestId(): string;
/**
* 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;
private getChoices;
}
//# sourceMappingURL=orchestration-response.d.ts.map