Skip to content

Commit 8109eb8

Browse files
committed
small fix
1 parent 2fa8a80 commit 8109eb8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutors;
1111
import java.io.IOException;
1212
import java.nio.charset.StandardCharsets;
13+
import java.nio.file.Files;
1314
import java.util.List;
1415
import javax.annotation.Nonnull;
1516
import javax.annotation.Nullable;
1617
import lombok.extern.slf4j.Slf4j;
1718
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.beans.factory.annotation.Value;
20+
import org.springframework.core.io.Resource;
1821
import org.springframework.core.io.ResourceLoader;
1922
import org.springframework.http.MediaType;
2023
import org.springframework.http.ResponseEntity;
@@ -34,6 +37,9 @@ class OrchestrationController {
3437
@Autowired private OrchestrationService service;
3538
@Autowired private ResourceLoader resourceLoader;
3639

40+
@Value("classpath:promptTemplateExample.yaml")
41+
private Resource localPromptTemplate;
42+
3743
@GetMapping("/completion")
3844
Object completion(
3945
@Nullable @RequestParam(value = "format", required = false) final String format) {
@@ -279,9 +285,8 @@ Object templateFromPromptRegistryByScenario(
279285
@Nonnull
280286
Object localPromptTemplate(@RequestParam(value = "format", required = false) final String format)
281287
throws IOException {
282-
final var resource = resourceLoader.getResource("classpath:promptTemplateExample.yaml");
283288
final var promptTemplate =
284-
new String(resource.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
289+
Files.readString(localPromptTemplate.getFile().toPath(), StandardCharsets.UTF_8);
285290
final var response = service.localPromptTemplate(promptTemplate);
286291
if ("json".equals(format)) {
287292
return response;

0 commit comments

Comments
 (0)