1010import com .sap .cloud .sdk .cloudplatform .thread .ThreadContextExecutors ;
1111import java .io .IOException ;
1212import java .nio .charset .StandardCharsets ;
13+ import java .nio .file .Files ;
1314import java .util .List ;
1415import javax .annotation .Nonnull ;
1516import javax .annotation .Nullable ;
1617import lombok .extern .slf4j .Slf4j ;
1718import org .springframework .beans .factory .annotation .Autowired ;
19+ import org .springframework .beans .factory .annotation .Value ;
20+ import org .springframework .core .io .Resource ;
1821import org .springframework .core .io .ResourceLoader ;
1922import org .springframework .http .MediaType ;
2023import 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