UNPKG

@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**.

81 lines 4.74 kB
import { OrchestrationStreamResponse } from './orchestration-stream-response.js'; import { OrchestrationResponse } from './orchestration-response.js'; import type { Xor } from '@sap-cloud-sdk/util'; import type { CustomRequestConfig } from '@sap-cloud-sdk/http-client'; import type { DeploymentIdConfig, ResourceGroupConfig } from '@sap-ai-sdk/ai-api/internal.js'; import type { OrchestrationModuleConfig, OrchestrationModuleConfigList, OrchestrationConfigRef, ChatCompletionRequest, StreamOptions, OrchestrationRequestHeaders } from './orchestration-types.js'; import type { OrchestrationStreamChunkResponse } from './orchestration-stream-chunk-response.js'; import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity'; /** * Client for the SAP AI Core Orchestration Service. * @remarks * The configuration (model, parameters, tools, etc.) is fixed at construction time. * To use different model parameters or tools for a specific request, * create a new `OrchestrationClient` instance with the desired configuration. */ export declare class OrchestrationClient { private config; private deploymentConfig?; private destination?; /** * Creates an instance of the orchestration client. * @param config - Orchestration configuration. Can be: * - An `OrchestrationModuleConfig` object for inline configuration * - An `OrchestrationModuleConfigList` array for module fallback (tries each config in order until one succeeds) * - A JSON string obtained from AI Launchpad * - An object of type`OrchestrationConfigRef` to reference a stored configuration by ID or name. * @param deploymentConfig - Deployment configuration. * @param destination - The destination to use for the request. */ constructor(config: string | Xor<OrchestrationConfigRef, OrchestrationModuleConfig | OrchestrationModuleConfigList>, deploymentConfig?: ResourceGroupConfig | DeploymentIdConfig | undefined, destination?: HttpDestinationOrFetchOptions | undefined); /** * Send a chat completion request to the orchestration service. * @param request - Request containing messages, placeholder values, and message history. * @param requestConfig - Additional request configuration. Use `requestConfig.headers` to pass service-specific headers: * - `AI-Object-Store-Secret-Name`: Name of the object store secret used by the feedback service. * @returns The orchestration service response. */ chatCompletion(request?: ChatCompletionRequest, requestConfig?: CustomRequestConfig & { headers?: OrchestrationRequestHeaders; }): Promise<OrchestrationResponse>; /** * Create a streaming chat completion request to the orchestration service. * @param request - Request containing messages, placeholder values, and message history. * @param signal - An abort signal to cancel the request. * @param options - Streaming options, e.g., for input/output filtering. * @param requestConfig - Additional request configuration. Use `requestConfig.headers` to pass service-specific headers: * - `AI-Object-Store-Secret-Name`: Name of the object store secret used by the feedback service. * @returns The orchestration stream response. */ stream(request?: ChatCompletionRequest, signal?: AbortSignal, options?: StreamOptions, requestConfig?: CustomRequestConfig & { headers?: OrchestrationRequestHeaders; }): Promise<OrchestrationStreamResponse<OrchestrationStreamChunkResponse>>; private executeRequest; private createStreamResponse; /** * Validate if a string is valid JSON. * @param config - The JSON string to validate. */ private validateJsonConfig; /** * Parse and merge templating into the config object. * @param config - The orchestration module configuration with templating either as object or string. * @returns The updated and merged orchestration module configuration. * @throws Error if the YAML parsing fails or if the parsed object does not conform to the expected schema. */ private parseAndMergeTemplating; /** * Parse a single orchestration module config, handling YAML prompt templates. * @param config - The orchestration module configuration. * @returns The parsed configuration. */ private parseTemplatingModule; /** * Parse and validate a list of orchestration module configs for fallback. * @param config - The array of configurations. * @returns The validated and parsed configuration list. * @throws {Error} If the array is empty or contains invalid elements. */ private parseModuleConfigList; } //# sourceMappingURL=orchestration-client.d.ts.map