Class OrchestrationClient
chatCompletion()
│
├── config(config, fallbackConfigs...)
│ │
│ └── promptTemplate(templateOrReference)
│ ├── execute()
│ ├── executeStream()
│ └── executeStreamDeltas()
│
├── configReference(configRef)
│ ├── execute()
│ ├── executeStream()
│ └── executeStreamDeltas()
│
└── lowLevel()
└── request(completionPostRequest)
├── execute()
├── executeStream()
└── executeStreamDeltas()
embeddings()
│
├── request(orchestrationEmbeddingRequest)
│ └── execute()
│
└── lowLevel()
└── request(embeddingsPostRequest)
└── execute()
High-level chat execution returns OrchestrationChatResponse; low-level execution
returns CompletionPostResponse. Embedding execution similarly returns OrchestrationEmbeddingResponse or EmbeddingsPostResponse. Use lowLevel() only
when supplying a custom generated request object.
Both chat APIs support text streaming and detailed deltas. Text streaming throws on an output content-filter finish reason; detailed streaming exposes that reason in the deltas. Close returned streams with try-with-resources. Streaming does not modify the configured request or shared stream options, so the same execution client can also be used for non-streaming calls.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassBuilder to select a local or referenced orchestration configuration for a chat completion.classClient to execute a configured chat completion with a regular or streaming response.classIntermediate builder to select a prompt template for a local orchestration configuration.classBuilder to select a high-level or low-level embedding request.classClient to execute a high-level embedding request.classBuilder to supply a custom low-level chat completion request.classClient to execute a custom low-level chat completion request.classBuilder to supply a custom low-level embedding request.classClient to execute a custom low-level embedding request. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.OrchestrationClient(com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination destination) Constructor with a custom destination, allowing for a custom resource group or otherwise custom destination. -
Method Summary
Modifier and TypeMethodDescriptionCreate a builder to configure and execute a chat completion.Create a builder to configure and execute an embedding request.protected CompletionPostResponseexecuteRequest(CompletionPostRequest request) Serializes the given request, executes it and deserializes the response.toCompletionPostRequest(PromptTemplate template, OrchestrationModuleConfig config, OrchestrationModuleConfig... fallbackConfigs) Convert the given prompt and config into a low-level request data object.withHeader(String key, String value) Create a new orchestration client with a custom header added to every call made with this client.withHeaders(Map<String, String> headers) Create a new orchestration client with multiple custom headers added to every call made with this client.withResourceGroup(String resourceGroup, String scenario) Create a new orchestration client for the given resource group and scenario.
-
Constructor Details
-
OrchestrationClient
public OrchestrationClient()Default constructor. -
OrchestrationClient
public OrchestrationClient(@Nonnull com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination destination) Constructor with a custom destination, allowing for a custom resource group or otherwise custom destination. The destination needs to be configured with a URL pointing to an orchestration service deployment. Typically, such a destination should be obtained usingAiCoreService.getInferenceDestination(String).Example:
new OrchestrationClient(new AiCoreService().getInferenceDestination("custom-rg").forScenario("orchestration"));- Parameters:
destination- the specificHttpDestinationto use.- See Also:
-
-
Method Details
-
toCompletionPostRequest
@Nonnull public static CompletionRequestConfiguration toCompletionPostRequest(@Nonnull PromptTemplate template, @Nonnull OrchestrationModuleConfig config, @Nonnull OrchestrationModuleConfig... fallbackConfigs) Convert the given prompt and config into a low-level request data object. The data object allows for further customization before sending the request.- Parameters:
template- thePromptTemplateto generate a completion for.config- theOrchestrationConfigconfiguration to use for the completion.fallbackConfigs- fallback configurations to use.- Returns:
- the low-level request data object to send to orchestration.
-
chatCompletion
Create a builder to configure and execute a chat completion.- Returns:
- a builder to configure the chat completion
-
executeRequest
@Nonnull protected CompletionPostResponse executeRequest(@Nonnull CompletionPostRequest request) throws OrchestrationClientException Serializes the given request, executes it and deserializes the response.Override this method to customize the request execution. For example, to modify the request object before it is sent, use:
@Override protected CompletionPostResponse executeRequest(@Nonnull CompletionPostRequest request) { request.setCustomField("myField", "myValue"); return super.executeRequest(request); }Alternatively, you can call this method directly with a fully custom request object.
- Parameters:
request- the request data object to send to orchestration.- Returns:
- the response data object from orchestration.
- Throws:
OrchestrationClientException- if the request fails.
-
embeddings
Create a builder to configure and execute an embedding request.- Returns:
- a builder to supply an embedding request or select the low-level API.
-
withHeader
Create a new orchestration client with a custom header added to every call made with this client.- Parameters:
key- the key of the custom header to add.value- the value of the custom header to add.- Returns:
- a new client.
- Since:
- 1.11.0
-
withHeaders
Create a new orchestration client with multiple custom headers added to every call made with this client.- Parameters:
headers- a map of key value pairs for the custom headers to add.- Returns:
- a new client.
- Since:
- 1.22.0
-
withResourceGroup
@Nonnull public OrchestrationClient withResourceGroup(@Nonnull String resourceGroup, @Nonnull String scenario) Create a new orchestration client for the given resource group and scenario.- Parameters:
resourceGroup- the resource group, usually"default".scenario- the scenario.- Returns:
- a new client configured with the resolved destination.
-